VSTS build doesn't fail on failed tests - azure-devops

I am using VSTS to run protractor e2e test cases. I have a npm custom task that run the tests and even if the test fails, vsts build doesn't fail.
How can I make the vsts build fail?

You could try using Write-Error in combination with an exit 1 to fail a task:
Write-Error ("Some error")
exit 1
Check the case below:
How to fail the build from a PowerShell task in TFS 2015

Related

2.170.1\Modules\DTAExecutionHost.exe' failed with exit code 1

I am trying to run my automation pipeline on Private hosted agent and getting error as Test Run Failed.
Error: The process 'C:\agent_work_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\2.170.1\Modules\DTAExecutionHost.exe' failed with exit code 1
Vstest failed with error. Check logs for failures. There might be failed tests.
Error: The process 'C:\agent_work_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\2.170.1\Modules\DTAExecutionHost.exe' failed with exit code 1 Vstest failed with error. Check logs for failures. There might be failed tests.
Based on the error message, the reason for this issue should be that the VSTest task supported .Net Framework 4.6.2 from version 2.170.1.
You need to check the .NET framework version installed on the build agent machine. If the .NET framework version installed on the machine is 4.6.1 or less than that then can you please try upgrading the .Net framework version to 4.6.2.
Here is a doc about the requirement about the Visual Studio test task:
If you're using a Windows self-hosted agent, be sure that your machine
has this prerequisite installed:
.NET Framework 4.6.2 or a later version
In addition, you can try to use the Visual Studio test task version 1.

Issue with ‘VsTest’ task in azure devops CI build

I am using sonarqube version 6.1 and i have sonarqube scanning task integrated with my azure CI build . I want to calculate code coverages too , so I have added VsTest task in my CI build (as mentioned in sonarqube-vsts integration documentation).
I am getting error in VsTest task when a build is queued . (All other sonarqube task is running fine)
The error is as below :
Error: The process ‘C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe’ failed with exit code 1
VsTest task failed.
Please let me know how can this be fixed . Build server I am using has VS2017 on it.
Here's the log :
Total tests: 14. Passed: 8. Failed: 6. Skipped: 0.
Test Run Failed.
Test execution time: 41.8253 Seconds
Results File: D:\VSTS Agent Folder\SO\41\s\TestResults\SC-DEOPSCI_MEA-DEVOPS1_2019-09-09_11_14_11.trx
##[warning]Vstest failed with error. Check logs for failures. There might be failed tests.
##[error]Error: The process 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe' failed with exit code 1
##[error]VsTest task failed.
Publishing test results to test run '1000042'
Test results remaining: 14. Test run id: 1000042
##[section]Async Command Start: Publish test results
Published Test Run : https://xyz.visualstudio.com/TipB/_TestManagement/Runs?runId=1000042&_a=runCharts
##[section]Async Command End: Publish test results
##[section]Finishing: VsTest - testAssemblies
The error shows that 6 tests failed. It is the expected behavior of Vstest task. When the tests failed, the task will fail too.
This may indicate that there is something going unexpectedly in your code. You should go back to your source code and fix the failed test cases. After they are fixed, you can rerun your pipeline.
If you didnot want failed tests to effect the next task after Vstest, You can change the Control option of the next task to run the this task even if the previous task has failed.

How can I solve error in teamcity (Nunit)?

Recently our NUnit build configuration has occasionally stopped halfway through the tests, but the overall build outcome is successful . When I look at the build log, the last test that actually got executed shows:
Process exited with code -100 (Step: tests (NUnit))
and then the build stops. Under "Failure Conditions". Our NUnit Consol is 3.10.0 .
Below is our NUnit configuration image.
I've found this comment in the TeamCity YouTrack. Seems, dotnet projects aren't supported in NUnit build step.
Try to use .NET CLI build step with "dotnet test" command to run tests in this project. Does it work?

run "clean-up": Job failed: exit status 1

I have Ionic pro, packaging for Android keeps failing with the following output:
$ run "clean-up"
Running Stage clean-up for Job: 5444336
ERROR: Job failed: exit status 1
The APK seems to generate correctly, but after the APK is generated this clean up command is attempted and fails.
Response from Ionic support:
I see you're using cordova-android 7.0.0. Unfortunately v7 isn't yet supported for package builds. You'll need to revert to v6.4.0 to complete the build. Have a look at this article for more details.

Continuous Integration: Codeship + Gulp (Jasmine)

My Continuous Integration works pretty great using Codeship except one thing: stop deploying and alert us when unit tests are failing.
Here is our current commands:
npm install
npm install bower
bower install
gulp test
gulp build
The problem is whether gulp test end with success or fail, the gulp build builds.
I succeed to console.log() my gulp test exit status but I have no idea about how to make Codeship listen to this exit status.
The build on Codeship will fail as soon as any command exits with an exit code other than zero.
Please make sure this is the case with running gulp test.
(You can also reach out to us via support#codeship.com if any other questions come up!)
Using #mlocker answer and this discussion on Github, I've found a workaround that works fine for me:
gulp.task('test', function (done) {
karma.start({}, function(exitStatus){
done(exitStatus ? "There are failing unit tests" : undefined);
});
});
The trick here is that if the exitStatus is different from 0, you'll get a formatError on "There are failing unit tests" which will exit gulp test with 1 making Codeship to stop and consider the build as failed.
maybe you can try chaining the test and build tasks?
gulp test && gulp build