xUnit with powershell sometimes fails

j.verdurmen's Avatar


17 Aug, 2015 08:45 PM


We have the problem that sometimes xUnit won't work well. We have a powershell script, and everything looks fine, but still it reports a failure.


Can you see what's wrong here? We use the `2> out-null`, because (in the recent) past, xUnit was crashed due to logging to the error stream .

  1. Support Staff 1 Posted by Feodor Fitsner on 17 Aug, 2015 08:52 PM

    Feodor Fitsner's Avatar

    Have you tried executing runners from batch ("CMD" mode)?
    Otherwise, try checking $LastExitCode instead of $?.

  2. 2 Posted by j.verdurmen on 17 Aug, 2015 09:06 PM

    j.verdurmen's Avatar

    Thanks for the fast response. We will try your proposals.

  3. 3 Posted by j.verdurmen on 17 Aug, 2015 09:12 PM

    j.verdurmen's Avatar

    With $LastExitCode we got the same results.
    See; https://ci.appveyor.com/project/Xharze/nlog-134/build/4.0.696

    I'm not sure how to convert to CMD for the test.

    Current code:


            xunit.console.clr4 "build\bin\Debug\.NET Framework 4.0\NLog.UnitTests.dll" /appveyor /noshadow 2> out-null

            $success = $LastExitCode

            xunit.console.clr4 "build\bin\Debug\.NET Framework 4.5\NLog.UnitTests.dll" /appveyor /noshadow 2> out-null

            if ( $success ) {
              $success = $LastExitCode

            xunit.console.clr4 "build\bin\Debug\.NET Framework 3.5\NLog.UnitTests.dll" /appveyor /noshadow 2> out-null

            if ( $success ) {
              $success = $LastExitCode

            if ( -not $success) {
               throw "tests not successfull"

  4. Support Staff 4 Posted by Feodor Fitsner on 18 Aug, 2015 12:01 AM

    Feodor Fitsner's Avatar
  5. 5 Posted by j.verdurmen on 21 Aug, 2015 06:58 PM

    j.verdurmen's Avatar


    It seems to work!

    Is this a "fail fast" solution?

  6. Support Staff 6 Posted by Feodor Fitsner on 22 Aug, 2015 04:38 AM

    Feodor Fitsner's Avatar


  7. 7 Posted by j.verdurmen on 02 Sep, 2015 08:55 PM

    j.verdurmen's Avatar

    I can confirm that aft er the changes to CMD, it wont have crashed.

    Thanks Feodor!

  8. j.verdurmen closed this discussion on 03 Apr, 2017 08:56 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac