|
| 1 | +--- |
| 2 | +name: Test trx-to-vsplaylist Action |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + - 'v*' |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + - 'v*' |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +jobs: |
| 16 | + test-action: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Create sample TRX files |
| 23 | + run: | |
| 24 | + mkdir -p TestResults |
| 25 | + |
| 26 | + # Create comprehensive TRX file with all test outcomes |
| 27 | + cat > TestResults/comprehensive.trx << 'EOF' |
| 28 | + <?xml version="1.0" encoding="utf-8"?> |
| 29 | + <TestRun id="12345678-1234-1234-1234-123456789012" name="Comprehensive Test Run" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010"> |
| 30 | + <Results> |
| 31 | + <UnitTestResult executionId="execution-1" testId="test-1" testName="FailedTest" computerName="TestComputer" duration="00:00:00.0010000" startTime="2023-01-01T12:00:00.000Z" endTime="2023-01-01T12:00:00.001Z" outcome="Failed" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d"> |
| 32 | + <Output> |
| 33 | + <ErrorInfo> |
| 34 | + <Message>Assert.AreEqual failed. Expected:<2>. Actual:<1>.</Message> |
| 35 | + </ErrorInfo> |
| 36 | + </Output> |
| 37 | + </UnitTestResult> |
| 38 | + <UnitTestResult executionId="execution-2" testId="test-2" testName="PassedTest" computerName="TestComputer" duration="00:00:00.0010000" startTime="2023-01-01T12:00:01.000Z" endTime="2023-01-01T12:00:01.001Z" outcome="Passed" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" /> |
| 39 | + <UnitTestResult executionId="execution-3" testId="test-3" testName="NotExecutedTest" computerName="TestComputer" duration="00:00:00.0000000" startTime="2023-01-01T12:00:02.000Z" endTime="2023-01-01T12:00:02.000Z" outcome="NotExecuted" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" /> |
| 40 | + <UnitTestResult executionId="execution-4" testId="test-4" testName="InconclusiveTest" computerName="TestComputer" duration="00:00:00.0010000" startTime="2023-01-01T12:00:03.000Z" endTime="2023-01-01T12:00:03.001Z" outcome="Inconclusive" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" /> |
| 41 | + <UnitTestResult executionId="execution-5" testId="test-5" testName="TimeoutTest" computerName="TestComputer" duration="00:00:30.0000000" startTime="2023-01-01T12:00:04.000Z" endTime="2023-01-01T12:00:34.000Z" outcome="Timeout" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" /> |
| 42 | + </Results> |
| 43 | + <TestDefinitions> |
| 44 | + <UnitTest name="FailedTest" id="test-1"> |
| 45 | + <TestMethod codeBase="TestAssembly.dll" adapterTypeName="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter" className="TestClass" name="FailedTest" /> |
| 46 | + </UnitTest> |
| 47 | + <UnitTest name="PassedTest" id="test-2"> |
| 48 | + <TestMethod codeBase="TestAssembly.dll" adapterTypeName="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter" className="TestClass" name="PassedTest" /> |
| 49 | + </UnitTest> |
| 50 | + <UnitTest name="NotExecutedTest" id="test-3"> |
| 51 | + <TestMethod codeBase="TestAssembly.dll" adapterTypeName="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter" className="TestClass" name="NotExecutedTest" /> |
| 52 | + </UnitTest> |
| 53 | + <UnitTest name="InconclusiveTest" id="test-4"> |
| 54 | + <TestMethod codeBase="TestAssembly.dll" adapterTypeName="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter" className="TestClass" name="InconclusiveTest" /> |
| 55 | + </UnitTest> |
| 56 | + <UnitTest name="TimeoutTest" id="test-5"> |
| 57 | + <TestMethod codeBase="TestAssembly.dll" adapterTypeName="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter" className="TestClass" name="TimeoutTest" /> |
| 58 | + </UnitTest> |
| 59 | + </TestDefinitions> |
| 60 | + </TestRun> |
| 61 | + EOF |
| 62 | + |
| 63 | + # Create simple TRX file for basic tests (keeping backward compatibility) |
| 64 | + cat > TestResults/sample.trx << 'EOF' |
| 65 | + <?xml version="1.0" encoding="utf-8"?> |
| 66 | + <TestRun id="12345678-1234-1234-1234-123456789012" name="Test Run" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010"> |
| 67 | + <Results> |
| 68 | + <UnitTestResult executionId="execution-1" testId="test-1" testName="TestMethod1" computerName="TestComputer" duration="00:00:00.0010000" startTime="2023-01-01T12:00:00.000Z" endTime="2023-01-01T12:00:00.001Z" outcome="Failed" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d"> |
| 69 | + <Output> |
| 70 | + <ErrorInfo> |
| 71 | + <Message>Assert.AreEqual failed. Expected:<2>. Actual:<1>.</Message> |
| 72 | + </ErrorInfo> |
| 73 | + </Output> |
| 74 | + </UnitTestResult> |
| 75 | + <UnitTestResult executionId="execution-2" testId="test-2" testName="TestMethod2" computerName="TestComputer" duration="00:00:00.0010000" startTime="2023-01-01T12:00:01.000Z" endTime="2023-01-01T12:00:01.001Z" outcome="Passed" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" /> |
| 76 | + </Results> |
| 77 | + <TestDefinitions> |
| 78 | + <UnitTest name="TestMethod1" id="test-1"> |
| 79 | + <TestMethod codeBase="TestAssembly.dll" adapterTypeName="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter" className="TestClass" name="TestMethod1" /> |
| 80 | + </UnitTest> |
| 81 | + <UnitTest name="TestMethod2" id="test-2"> |
| 82 | + <TestMethod codeBase="TestAssembly.dll" adapterTypeName="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter" className="TestClass" name="TestMethod2" /> |
| 83 | + </UnitTest> |
| 84 | + </TestDefinitions> |
| 85 | + </TestRun> |
| 86 | + EOF |
| 87 | + |
| 88 | + # Create additional TRX file for glob pattern testing |
| 89 | + cat > TestResults/additional.trx << 'EOF' |
| 90 | + <?xml version="1.0" encoding="utf-8"?> |
| 91 | + <TestRun id="87654321-4321-4321-4321-210987654321" name="Additional Test Run" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010"> |
| 92 | + <Results> |
| 93 | + <UnitTestResult executionId="execution-1" testId="test-1" testName="AdditionalTest" computerName="TestComputer" duration="00:00:00.0010000" startTime="2023-01-01T12:00:00.000Z" endTime="2023-01-01T12:00:00.001Z" outcome="Failed" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" /> |
| 94 | + </Results> |
| 95 | + <TestDefinitions> |
| 96 | + <UnitTest name="AdditionalTest" id="test-1"> |
| 97 | + <TestMethod codeBase="TestAssembly.dll" adapterTypeName="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter" className="TestClass" name="AdditionalTest" /> |
| 98 | + </UnitTest> |
| 99 | + </TestDefinitions> |
| 100 | + </TestRun> |
| 101 | + EOF |
| 102 | +
|
| 103 | + - name: Test Action - Basic Usage |
| 104 | + uses: ./ |
| 105 | + with: |
| 106 | + trx-file-path: './TestResults/sample.trx' |
| 107 | + artifact-name: 'test-playlist-basic' |
| 108 | + |
| 109 | + - name: Verify playlist file was created |
| 110 | + run: | |
| 111 | + if [ -f "./TestResults/sample.playlist" ]; then |
| 112 | + echo "✅ Playlist file created successfully" |
| 113 | + echo "Content:" |
| 114 | + cat "./TestResults/sample.playlist" |
| 115 | + else |
| 116 | + echo "❌ Playlist file not found" |
| 117 | + exit 1 |
| 118 | + fi |
| 119 | +
|
| 120 | + - name: Test Action - Custom Output Path |
| 121 | + uses: ./ |
| 122 | + with: |
| 123 | + trx-file-path: './TestResults/sample.trx' |
| 124 | + output-path: './custom-playlist.playlist' |
| 125 | + test-outcomes: 'Failed,Passed' |
| 126 | + artifact-name: 'test-playlist-custom' |
| 127 | + |
| 128 | + - name: Verify custom playlist file was created |
| 129 | + run: | |
| 130 | + if [ -f "./custom-playlist.playlist" ]; then |
| 131 | + echo "✅ Custom playlist file created successfully" |
| 132 | + echo "Content:" |
| 133 | + cat "./custom-playlist.playlist" |
| 134 | + else |
| 135 | + echo "❌ Custom playlist file not found" |
| 136 | + exit 1 |
| 137 | + fi |
| 138 | +
|
| 139 | + # Test individual test outcomes |
| 140 | + - name: Test Action - Passed outcomes only |
| 141 | + uses: ./ |
| 142 | + with: |
| 143 | + trx-file-path: './TestResults/comprehensive.trx' |
| 144 | + output-path: './passed-only.playlist' |
| 145 | + test-outcomes: 'Passed' |
| 146 | + artifact-name: 'test-playlist-passed' |
| 147 | + |
| 148 | + - name: Verify passed-only playlist |
| 149 | + run: | |
| 150 | + if [ -f "./passed-only.playlist" ]; then |
| 151 | + echo "✅ Passed-only playlist created successfully" |
| 152 | + echo "Content:" |
| 153 | + cat "./passed-only.playlist" |
| 154 | + # Should contain only PassedTest |
| 155 | + if grep -q "PassedTest" "./passed-only.playlist"; then |
| 156 | + echo "✅ Contains expected PassedTest" |
| 157 | + else |
| 158 | + echo "❌ Missing expected PassedTest" |
| 159 | + exit 1 |
| 160 | + fi |
| 161 | + else |
| 162 | + echo "❌ Passed-only playlist file not found" |
| 163 | + exit 1 |
| 164 | + fi |
| 165 | +
|
| 166 | + - name: Test Action - NotExecuted outcomes only |
| 167 | + uses: ./ |
| 168 | + with: |
| 169 | + trx-file-path: './TestResults/comprehensive.trx' |
| 170 | + output-path: './notexecuted-only.playlist' |
| 171 | + test-outcomes: 'NotExecuted' |
| 172 | + artifact-name: 'test-playlist-notexecuted' |
| 173 | + |
| 174 | + - name: Verify NotExecuted-only playlist |
| 175 | + run: | |
| 176 | + if [ -f "./notexecuted-only.playlist" ]; then |
| 177 | + echo "✅ NotExecuted-only playlist created successfully" |
| 178 | + echo "Content:" |
| 179 | + cat "./notexecuted-only.playlist" |
| 180 | + # Should contain only NotExecutedTest |
| 181 | + if grep -q "NotExecutedTest" "./notexecuted-only.playlist"; then |
| 182 | + echo "✅ Contains expected NotExecutedTest" |
| 183 | + else |
| 184 | + echo "❌ Missing expected NotExecutedTest" |
| 185 | + exit 1 |
| 186 | + fi |
| 187 | + else |
| 188 | + echo "❌ NotExecuted-only playlist file not found" |
| 189 | + exit 1 |
| 190 | + fi |
| 191 | +
|
| 192 | + - name: Test Action - Inconclusive outcomes only |
| 193 | + uses: ./ |
| 194 | + with: |
| 195 | + trx-file-path: './TestResults/comprehensive.trx' |
| 196 | + output-path: './inconclusive-only.playlist' |
| 197 | + test-outcomes: 'Inconclusive' |
| 198 | + artifact-name: 'test-playlist-inconclusive' |
| 199 | + |
| 200 | + - name: Verify Inconclusive-only playlist |
| 201 | + run: | |
| 202 | + if [ -f "./inconclusive-only.playlist" ]; then |
| 203 | + echo "✅ Inconclusive-only playlist created successfully" |
| 204 | + echo "Content:" |
| 205 | + cat "./inconclusive-only.playlist" |
| 206 | + # Should contain only InconclusiveTest |
| 207 | + if grep -q "InconclusiveTest" "./inconclusive-only.playlist"; then |
| 208 | + echo "✅ Contains expected InconclusiveTest" |
| 209 | + else |
| 210 | + echo "❌ Missing expected InconclusiveTest" |
| 211 | + exit 1 |
| 212 | + fi |
| 213 | + else |
| 214 | + echo "❌ Inconclusive-only playlist file not found" |
| 215 | + exit 1 |
| 216 | + fi |
| 217 | +
|
| 218 | + - name: Test Action - Timeout outcomes only |
| 219 | + uses: ./ |
| 220 | + with: |
| 221 | + trx-file-path: './TestResults/comprehensive.trx' |
| 222 | + output-path: './timeout-only.playlist' |
| 223 | + test-outcomes: 'Timeout' |
| 224 | + artifact-name: 'test-playlist-timeout' |
| 225 | + |
| 226 | + - name: Verify Timeout-only playlist |
| 227 | + run: | |
| 228 | + if [ -f "./timeout-only.playlist" ]; then |
| 229 | + echo "✅ Timeout-only playlist created successfully" |
| 230 | + echo "Content:" |
| 231 | + cat "./timeout-only.playlist" |
| 232 | + # Should contain only TimeoutTest |
| 233 | + if grep -q "TimeoutTest" "./timeout-only.playlist"; then |
| 234 | + echo "✅ Contains expected TimeoutTest" |
| 235 | + else |
| 236 | + echo "❌ Missing expected TimeoutTest" |
| 237 | + exit 1 |
| 238 | + fi |
| 239 | + else |
| 240 | + echo "❌ Timeout-only playlist file not found" |
| 241 | + exit 1 |
| 242 | + fi |
| 243 | +
|
| 244 | + # Test all outcomes combined |
| 245 | + - name: Test Action - All outcomes combined |
| 246 | + uses: ./ |
| 247 | + with: |
| 248 | + trx-file-path: './TestResults/comprehensive.trx' |
| 249 | + output-path: './all-outcomes.playlist' |
| 250 | + test-outcomes: 'Failed,Passed,NotExecuted,Inconclusive,Timeout' |
| 251 | + artifact-name: 'test-playlist-all' |
| 252 | + |
| 253 | + - name: Verify all-outcomes playlist |
| 254 | + run: | |
| 255 | + if [ -f "./all-outcomes.playlist" ]; then |
| 256 | + echo "✅ All-outcomes playlist created successfully" |
| 257 | + echo "Content:" |
| 258 | + cat "./all-outcomes.playlist" |
| 259 | + # Should contain all test types |
| 260 | + TESTS=("FailedTest" "PassedTest" "NotExecutedTest" "InconclusiveTest" "TimeoutTest") |
| 261 | + for test in "${TESTS[@]}"; do |
| 262 | + if grep -q "$test" "./all-outcomes.playlist"; then |
| 263 | + echo "✅ Contains expected $test" |
| 264 | + else |
| 265 | + echo "❌ Missing expected $test" |
| 266 | + exit 1 |
| 267 | + fi |
| 268 | + done |
| 269 | + else |
| 270 | + echo "❌ All-outcomes playlist file not found" |
| 271 | + exit 1 |
| 272 | + fi |
| 273 | +
|
| 274 | + # Test whitespace handling in test-outcomes |
| 275 | + - name: Test Action - Whitespace in test-outcomes |
| 276 | + uses: ./ |
| 277 | + with: |
| 278 | + trx-file-path: './TestResults/comprehensive.trx' |
| 279 | + output-path: './whitespace-test.playlist' |
| 280 | + test-outcomes: ' Failed , Passed , NotExecuted ' |
| 281 | + artifact-name: 'test-playlist-whitespace' |
| 282 | + |
| 283 | + - name: Verify whitespace handling |
| 284 | + run: | |
| 285 | + if [ -f "./whitespace-test.playlist" ]; then |
| 286 | + echo "✅ Whitespace test playlist created successfully" |
| 287 | + echo "Content:" |
| 288 | + cat "./whitespace-test.playlist" |
| 289 | + # Should contain Failed, Passed, and NotExecuted tests |
| 290 | + TESTS=("FailedTest" "PassedTest" "NotExecutedTest") |
| 291 | + for test in "${TESTS[@]}"; do |
| 292 | + if grep -q "$test" "./whitespace-test.playlist"; then |
| 293 | + echo "✅ Contains expected $test" |
| 294 | + else |
| 295 | + echo "❌ Missing expected $test" |
| 296 | + exit 1 |
| 297 | + fi |
| 298 | + done |
| 299 | + else |
| 300 | + echo "❌ Whitespace test playlist file not found" |
| 301 | + exit 1 |
| 302 | + fi |
| 303 | +
|
| 304 | + # Test glob pattern support |
| 305 | + - name: Test Action - Glob pattern support |
| 306 | + uses: ./ |
| 307 | + with: |
| 308 | + trx-file-path: './TestResults/*.trx' |
| 309 | + output-path: './glob-test.playlist' |
| 310 | + test-outcomes: 'Failed' |
| 311 | + artifact-name: 'test-playlist-glob' |
| 312 | + |
| 313 | + - name: Verify glob pattern handling |
| 314 | + run: | |
| 315 | + if [ -f "./glob-test.playlist" ]; then |
| 316 | + echo "✅ Glob pattern test playlist created successfully" |
| 317 | + echo "Content:" |
| 318 | + cat "./glob-test.playlist" |
| 319 | + # Should use the first matching TRX file (which could be any of them) |
| 320 | + echo "✅ Glob pattern processed successfully" |
| 321 | + else |
| 322 | + echo "❌ Glob pattern test playlist file not found" |
| 323 | + exit 1 |
| 324 | + fi |
| 325 | +
|
| 326 | + # Test default artifact name behavior |
| 327 | + - name: Test Action - Default artifact name |
| 328 | + uses: ./ |
| 329 | + with: |
| 330 | + trx-file-path: './TestResults/comprehensive.trx' |
| 331 | + test-outcomes: 'Failed' |
| 332 | + # Note: not specifying artifact-name to test default behavior |
| 333 | + |
| 334 | + - name: Verify default playlist file creation |
| 335 | + run: | |
| 336 | + if [ -f "./TestResults/comprehensive.playlist" ]; then |
| 337 | + echo "✅ Default playlist file created successfully" |
| 338 | + echo "Content:" |
| 339 | + cat "./TestResults/comprehensive.playlist" |
| 340 | + else |
| 341 | + echo "❌ Default playlist file not found" |
| 342 | + exit 1 |
| 343 | + fi |
| 344 | +
|
| 345 | + test-error-conditions: |
| 346 | + runs-on: ubuntu-latest |
| 347 | + steps: |
| 348 | + - name: Checkout |
| 349 | + uses: actions/checkout@v4 |
| 350 | + |
| 351 | + - name: Test Action - Missing TRX file (should fail) |
| 352 | + id: missing-trx-test |
| 353 | + uses: ./ |
| 354 | + continue-on-error: true |
| 355 | + with: |
| 356 | + trx-file-path: './NonExistent/missing.trx' |
| 357 | + artifact-name: 'test-playlist-error' |
| 358 | + |
| 359 | + - name: Verify missing TRX file error handling |
| 360 | + run: | |
| 361 | + if [ "${{ steps.missing-trx-test.outcome }}" = "failure" ]; then |
| 362 | + echo "✅ Action correctly failed for missing TRX file" |
| 363 | + else |
| 364 | + echo "❌ Action should have failed for missing TRX file" |
| 365 | + exit 1 |
| 366 | + fi |
0 commit comments