xUnit with powershell sometimes fails
Hi,
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.
https://ci.appveyor.com/project/Xharze/nlog-134/build/4.0.692
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 .
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
| ? | 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

Support Staff 1 Posted by Feodor Fitsner on 17 Aug, 2015 08:52 PM
Have you tried executing runners from batch ("CMD" mode)?
Otherwise, try checking
$LastExitCodeinstead of$?.2 Posted by j.verdurmen on 17 Aug, 2015 09:06 PM
Thanks for the fast response. We will try your proposals.
3 Posted by j.verdurmen on 17 Aug, 2015 09:12 PM
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:
.\tests\CreateTestUsers.cmd
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"
Support Staff 4 Posted by Feodor Fitsner on 18 Aug, 2015 12:01 AM
Like that: https://github.com/FeodorFitsner/NLog/blob/master/appveyor.yml
Build results: https://ci.appveyor.com/project/FeodorFitsner/nlog/build/4.0.2
5 Posted by j.verdurmen on 21 Aug, 2015 06:58 PM
Thanks!
It seems to work!
Is this a "fail fast" solution?
Support Staff 6 Posted by Feodor Fitsner on 22 Aug, 2015 04:38 AM
Yep.
7 Posted by j.verdurmen on 02 Sep, 2015 08:55 PM
I can confirm that aft er the changes to CMD, it wont have crashed.
Thanks Feodor!
j.verdurmen closed this discussion on 03 Apr, 2017 08:56 PM.