Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

All tests failed due to unexpected error
AlexanderG
#1 Posted : Wednesday, November 1, 2017 5:35:11 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/1/2017(UTC)
Posts: 3

Hi, I'm experiencing strange behavior (working on dotnetcore 2.0 app, using VS2017):
After launching VS and enabling ncrunch all tests run fine. If I change a line of code, all tests fail with the following reason:
NCrunch was unable to retrieve a meaningful result from this test due to an unexpected error - was the execution process terminated?
If I click Reset or re-launch VS tests work fine again until I change something in code.

If it helps, I can upload the project I'm working on.

Regards,
Alex
Remco
#2 Posted : Wednesday, November 1, 2017 10:18:47 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi Alex,

Thanks for sharing this issue. This problem is occurring because something is taking out the nCrunch.TestHost process responsible for running your tests. The timing of the error suggests that this is happening during test execution. I find it interesting that after a fresh reset, the problem goes away. It's possible that the issue is sequence dependent or intermittent.

What is the memory consumption like in your test process? Do you still see this problem if you choose to use an x64 test runner process?

Something else worth trying:
1. Let your tests do their initial run through, when everything is ok
2. Set the NCrunch engine to manual
3. Make a code change
4. Try running the affected tests with a debugger attached
5. See if the debugger reports an unexpected explosion
AlexanderG
#3 Posted : Wednesday, November 1, 2017 11:18:47 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/1/2017(UTC)
Posts: 3

Hi Remco,

The memory consumption is pretty low, it's a small project with 15 tests. I have tried x64 test runner and the problem is still there.
I have also tried to run tests with debugger and I don't see any exceptions.
To investigate further, I have used process explorer tool and noticed the following:
When running tests, EngineHost x64 launches dotnet.exe, which then crashes (WerFault.exe child process appears). I have checked windows logs and found this info on the crash:
Faulting application name: dotnet.exe, version: 2.0.25521.1, time stamp: 0x597139df
Exception code: 0x80131623 (COR_E_FAILFAST)
Fault offset: 0x00007ff8e316199f
P1: C:\Program Files\dotnet\dotnet.exe
P2: 2.0.25521.1
P3: 597139df
P4: Attache.Online.ConfigTool.DotNetCore
P5: 1.0.0.0
P6: 59fa4f41
P7: 111
P8: 4a
P9: FatalError
Interestingly enough, when I reset ncrunch or re-launch VS and run the tests, dotnet.exe still crashes, yet ncrunch reports that all tests are OK.

Also, I found out that tests start working when I rebuild the solution.

Regards,
Alex
Remco
#4 Posted : Thursday, November 2, 2017 6:18:00 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi Alex,

When you run the tests with a debugger, do they return to the runner with the expected result? (i.e. does the runner work correctly?)

Do you experience this problem with any other .NET Core solutions on your machine? If you create a sample .NET Core test framework using the same test framework, does it blow up in the same way?

Otherwise, I'd really be interested in looking into a solution that can produce this problem. If you're able to share this solution with me or alternatively a sample that can produce the problem, you can share this with me by zipping it up and submitting it through the NCrunch contact form.
AlexanderG
#5 Posted : Thursday, November 2, 2017 11:08:08 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/1/2017(UTC)
Posts: 3

Hi Remco,

Yes, running tests with debugger works, and the test turns green on completion. Funny enough, any test that I debug will turn green and stay so even after making changes to the code (same thing happens when I "run selected test in a new process").
I have one other .NET core project with tests and it works fine with ncrunch.
I have tried creating a new NUnit + dotnetcore project and ncrunch works fine.

I have uploaded the project using the contact form.

Regards,
Alex
Remco
#6 Posted : Friday, November 3, 2017 4:34:50 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks Alex. I'll take a look and will get back to you soon.
Remco
#7 Posted : Monday, November 6, 2017 12:30:39 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi Alex,

Thanks for sending through the sample solution.

The problem is being caused by a call to Debug.Fail in the destructor of XmlFileInfoDocument.

As I understand it, destructors are called when the GC physically removes objects from the heap. This code being in a destructor essentially creates a time-bomb that will explode shortly after the test run is completed, when the GC performs its cleanup after test results are returned.

It's likely this problem only showed up for you under NCrunch because NCrunch makes a call to GC.Collect() after test results are returned to the engine. This is done to ensure the test process doesn't consume more memory than it needs to between test runs. Other runners would have torn down the test process immediately after the run, so the destructor wouldn't have had time to execute.

Avoid throwing exceptions in destructors. These cause cryptic problems in the runtime and will give you nothing but pain.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.051 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download