azure-pipelines-tasks: VsTest task fails even when all tests passed
We have a project where VsTest
task consistently fails even when all tests passed.
In the log, I see this:
2017-01-22T16:22:52.4050809Z Total tests: 150. Passed: 149. Failed: 0. Skipped: 1.
2017-01-22T16:22:52.4050809Z Test Run Successful.
2017-01-22T16:22:52.4050809Z Test execution time: 17.1337 Minutes
2017-01-22T16:22:52.5342314Z ##[debug]rc:0
2017-01-22T16:22:52.5342314Z ##[debug]success:false
2017-01-22T16:22:52.5342314Z ##[warning]Vstest failed with error. Check logs for failures. There might be failed tests.
2017-01-22T16:22:52.5461701Z ##[error]Error: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe failed with return code: 0
When I download and open the .trx
file from the build agent and open in Visual Studio, it says that all tests passed (one is skipped, because it is marked using the Ignore
attribute which is correct).
The version of VsTest task is 2.0.5
(C:\BuildAgent\tasks\VSTest\2.0.5)
We are using the default configuration, no special options. We have installed both VS 2015 and VS 2017 RC on the build agent.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 10
- Comments: 18 (6 by maintainers)
Commits related to this issue
- Update vstest.ts `vstest.console.exe` writes to stderr when there are inconclusive or ignored tests which causes this task to fail, even if all tests are successful and `vstest.console.exe` returns c... — committed to ChristopherHaws/vso-agent-tasks by ChristopherHaws 7 years ago
- Ignore stderr errors when running vstest.console.exe `vstest.console.exe` writes to stderr when there are inconclusive or ignored tests which causes this task to fail, even if all tests are successfu... — committed to ChristopherHaws/vso-agent-tasks by ChristopherHaws 7 years ago
@nigurr I am using the vstest task v2 that uses the
Visual Studio Test Platform Installer
of version 15.7.2. All tests pass and there are no skipped or inconclusive tests but the task is still marked as red. The tests are usingNUnit3
. Here is the log (replaced some sensitive information like machine names, fileshares and product info):P.S. I noticed that this seems to be due to our test runsettings still pointing to an old NUnitv2 test adapter path but the point is that whatever happens, only the test results should be used to mark it red or not. If something unexpected like this happens, you can still mark it as orange to warn about it.
I have the same problem.
all tests passed, 2 skipped tests, but agent determines that the build fails. Using NUnit 3.6.0 and NUnitTestAdapters 3.7.0
It does because Skipped tests generate error messages when running 2>error.text
Finally, I found the issue. Well mine is a bit unexpected. Some very capable developer decided to check in the bin release folder into source control. The checked in folder contained nunit 2 test adapter. Even though it’s in a totally different folder as my nunit 3 tests, somehow it vstest decides to try and use the version 2 adapter to run my nunit 3 tests. Even though within the same folder, there is nunit 3 test adapter dlls also. I can finally stop pulling my hair out now. 😦
So my final solution was to delete those old bin folders and get on with my life.
@nigurr Your link does not explain how we can use the vstest task with skipped tests and have the task only fail on failed tests. The PR above by @ChristopherHaws (#3558) could have helped you to achieve this I have a case where there are no skipped tests but it still marks it as red because vstestconsole.exe returns an exit code of 1.