Handle failTaskOnFailedTests option - Azure Test Plan #20712
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Task name: AzureTestPlanV0
Description:
We provide option - failTaskOnFailedTests
Issue:
Currently, we are ignoring this option in our implementation of Java-Maven and Java-Gradle. As in by default, the option failTaskOnFailedTests is unchecked (false), still we fail the task incase of test failure as per below,
To investigate further, below is screenshot is when failTaskOnFailedTests is true
Here, we see third error coming up - There are one or more test failures detected in result files. Detailed summary of published test results can be viewed in the Tests tab. This error comes from Publish Test Results command, as we pass failTaskOnFailedTests to it, and it behaves as expected.
It is evident that for our usecase maven or gradle invoker should not conclude failure incase of test failure as that is handled by Publish Test Results command for us.
Solution:
As discussed above, we want maven or gradle invoker to not conclude failure incase of test failure, while reporting failure as expected incase of other variety of possible failures.
Maven provides: -Dmaven.test.failure.ignore=true that does the job of returning success exit code incase of test failure and later we can detect test failure from PTR command.
Gradle does not provide option similar to maven nor has different exit code to distinguish between failures of different types, so we will read stdout and conclude if non-success exit code is due to test failure or not.
As we provide ATP as Test task, by default failTaskOnFailedTests should be true, task should fail incase of test failure.
Screenshots after change:
Maven, failTaskOnFailedTests as False, (task passes indicated by grin tick on the top)
Maven, failTaskOnFailedTests as True (task does not pass and produces single and correct error)
Gradle, failTaskOnFailedTests as False, (task passes indicated by grin tick on the top)
Gradle, failTaskOnFailedTests as True (task does not pass and produces single and correct error)