Hi all.
I've been investigating this for a while, and I finally got a repro (along with an idea of what is happening).
I run NUnit tests invoked by vstest.console.exe, and using the NUnit adapter.
NUnit adapter version is 1.0, and NUnit framework is 2.6.3 (both seem to be the latest).
I have the following code:
[Test]
[Description("Thread sleep causes NUnit adapter to behave weird")]
public void NUnitAdapterBug1()
{
Thread.Sleep(5 * 60 * 1000);
throw new Exception("NUnit bug repro attempt");
}
I also have a TestInitialize method which just prints out 'calling TestInitialize', so I won't paste it here.
when the Thread.Sleep() line is commented out, the test runs fine, failing as expected (see screenshot 1).
But when Thread.Sleep is enabled, even for 5 minutes, the test is just aborted somewhere during the run, and all I see is the log from TestInitialize() (see screenshot 2).
Here is how I invoke the test:
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" <Path_To_DLL> /Platform:x64 /Framework:Framework45 /tests:NUnitAdapterBug1 /TestAdapterPath:"E:\NuGetPackages\NUnitTestAdapter.1.0\lib"
Has anyone else encountered similar issues? Is this a timeout being hit? If so, anyone knows how to work around it ?
Thanks
Thanks for the prompt response, Charlie. Here are the answers to your suggestions:
1. Run All - this is where I originally observed this bug. By running all tests in the lab environment (TFS). So it manifests both when running all tests and when running a test subset
2. Mark test with [RequiresThread] - this did not help, the behavior is exactly the same.
3. I will try this approach, but this will require rewriting all of our test infrastructure code, which is something we would try to avoid.
Your conclusion is correct - the adapter 'thinks' the test run is over way before the tests are actually done running.
Were you able to repro this issue ?
Thank you.
Can’t reproduce.
[TestFixture]
public class Class1
{
[SetUp]
public void Setup()
{
Console.WriteLine("Setup");
}
[TearDown]
public void Teardown()
{
Console.WriteLine("Teardown");
}
[Test]
[Description("Thread sleep causes NUnit adapter to behave weird")]
public void NUnitAdapterBug1()
{
Thread.Sleep(5 * 60 * 1000);
throw new Exception("NUnit bug repro attempt");
}
}
C:\Program Files (x86)\Microsoft Visual Studio 12.0>vstest.console.exe "D:\Users\Simone\Documents\Visual Studio 2013\Projects\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll" /Platform:x64 /Framework:Framework45 /TestAdapterPath:"D:\Users\Simone\Documents\Visual Studio 2013\Projects\ClassLibrary1\packages\NUnitTestAdapter.1.0\lib"
Microsoft (R) Test Execution Command Line Tool Version 12.0.21005.1
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Warning: Using Isolation mode to run tests as required by effective Platform:X64 and .Net Framework:Framework45 settings for test run. Use the /inIsolation parameter to suppress this warning.
Information: NUnit 1.0.0.0 executing tests is started
Information: Run started: D:\Users\Simone\Documents\Visual Studio 2013\Projects\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll
Information: Setup
Information: Teardown
Information: NUnit 1.0.0.0 executing tests is finished
Failed NUnitAdapterBug1
Error Message:
System.Exception : NUnit bug repro attempt
Stack Trace:
at ClassLibrary1.Class1.NUnitAdapterBug1() in d:\Users\Simone\Documents\Visual Studio 2013\Projects\ClassLibrary1\ClassLibrary1\Class1.cs:line 32
Standard Output Messages:
Teardown
Total tests: 1. Passed: 0. Failed: 1. Skipped: 0.
Test Run Failed.
Test execution time: 5,0131 Minutes
--
Hi Simone, and thank you for stepping in. Can you please increase the Sleep to 9 minutes and try?
I started from scratch by repeating your steps (except I use VS2012) and the 5 minutes sleep works for me too. But for 9 minutes it's failing with a warning that "NO TEST IS AVAILABLE". Please see attached screenshot for the output I got in both cases.
Thank you.
--
--
--
You received this message because you are subscribed to a topic in the Google Groups "NUnit-Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nunit-discuss/fCMZ4I-rNJQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nunit-discus...@googlegroups.com.
Sleep: 943998
The thread '<No Name>' (0x1bbc) has exited with code 0 (0x0).
The thread '<No Name>' (0xe14) has exited with code 0 (0x0).
The thread '<No Name>' (0x1934) has exited with code 0 (0x0).
The thread '<No Name>' (0x2f80) has exited with code 0 (0x0).
The thread '<No Name>' (0x25cc) has exited with code 0 (0x0).
The thread '<No Name>' (0x2e6c) has exited with code 0 (0x0).
The thread '<No Name>' (0x26a0) has exited with code 0 (0x0).
The thread '<No Name>' (0x25e0) has exited with code 0 (0x0).
The thread '<No Name>' (0x2a4c) has exited with code 0 (0x0).
A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll
An exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll but was not handled in user code
The thread '<No Name>' (0x2d08) has exited with code 0 (0x0).
The thread 'TestRunnerThread' (0x1dc0) has exited with code 0 (0x0).
The thread 'EventPumpThread' (0x2044) has exited with code 0 (0x0).
System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>vstest.executionengine.x86.exe</AppDomain><Exception><ExceptionType>System.AppDomainUnloadedException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Attempted to access an unloaded AppDomain.</Message><StackTrace>
</StackTrace><ExceptionString>System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain.</ExceptionString></Exception></TraceRecord>
The thread '<No Name>' (0x2ddc) has exited with code 0 (0x0).
The thread '<No Name>' (0x1d6c) has exited with code 0 (0x0).
The thread '<No Name>' (0x2fdc) has exited with code 0 (0x0).
The program '[9556] vstest.executionengine.x86.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).