3

I'm using TeamCity to build my .NET Core project and dotnet test with xunit to run tests.

My build is configured to fail if any tests fail, and this works fine if a test fails, but when the test project doesn't compile the exit code ends up being zero.

I believe this is because I run dotnet test in the folder that contains the test-directories like this: for /f %%%a in ('dir /b /s project.json') do dotnet test %%%a.

Looking at the log I can see the individual jobs that do not compile return with exit code 1, but the build step itself returns with exit code 0.

How can I make the exit code from the failed compilation attempts propagate down to the build step?

severin
  • 5,203
  • 9
  • 35
  • 48

1 Answers1

3

You may create a separate step in TC to just compile target test project, and then run tests without compilation (using no-build option) in next step (if all previous steps were successful).

--no-build
Does not build the test project prior to running it.
Set
  • 47,577
  • 22
  • 132
  • 150