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

Notification

Icon
Error

TargetInvocationException
ericschmidt
#1 Posted : Thursday, June 15, 2017 11:51:09 PM(UTC)
Rank: Member

Groups: Registered
Joined: 12/30/2016(UTC)
Posts: 18
Location: United States of America

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
I have several tests that seem to randomly fail because of a TargetInvocationException. If I re-run the tests, they pass. This has started to make things extremely difficult to understand if a failing test is actually failing or not. Any idea what might be causing this issue to occur?
Remco
#2 Posted : Friday, June 16, 2017 12:44:37 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
Hi,

This smells like sequence dependent behaviour.

When you re-run a test specifically, NCrunch will launch it in a new process. Thus all existing state is cleared. If the test is failing because of state left by a previously executed test in the process, it will always pass when run in a new process.

After a test fails in this manner, try running it via the 'Advanced->Debug selected test in existing task runner process'. This should allow you to get a debugger on the test when it misbehaves and hopefully learn more about the problem.
ericschmidt
#3 Posted : Friday, June 16, 2017 12:46:35 AM(UTC)
Rank: Member

Groups: Registered
Joined: 12/30/2016(UTC)
Posts: 18
Location: United States of America

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
Thank you, I'll try that and see if I can figure out what's causing it.
ericschmidt
#4 Posted : Tuesday, June 20, 2017 12:22:09 AM(UTC)
Rank: Member

Groups: Registered
Joined: 12/30/2016(UTC)
Posts: 18
Location: United States of America

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
I tried your suggestion of debugging using the existing task runner project, but even that resulted in a passing test. I have noticed that our project has a "Abnormal runtime assembly reference resolution detected" warning that shows up. Is it possible that this is causing the TargetInvocationExceptions? Or is there something else I should look for?
Remco
#5 Posted : Tuesday, June 20, 2017 3:30:07 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
ericschmidt;10659 wrote:
I tried your suggestion of debugging using the existing task runner project, but even that resulted in a passing test. I have noticed that our project has a "Abnormal runtime assembly reference resolution detected" warning that shows up. Is it possible that this is causing the TargetInvocationExceptions? Or is there something else I should look for?


It's possible that this could be causing the problem. NCrunch gives this warning when it detects an assembly being loaded by the CLR from the wrong place. If the assembly also happens to be different to the intended target, this could create problems.

Try turning on the preload assembly references setting for your test project to see if this makes any difference.

Are you able to be any more specific about the TargetInvocationException you're receiving? Is this being thrown within your own code?
ericschmidt
#6 Posted : Tuesday, June 20, 2017 7:34:01 PM(UTC)
Rank: Member

Groups: Registered
Joined: 12/30/2016(UTC)
Posts: 18
Location: United States of America

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
I'm pretty sure I found my problem. It turns out there was some PropertyChanged logic that was executing in a specific context that was causing the exception. I thought it was something else because of the TargetInvocationException and didn't look closely enough and the InnerException's being thrown. Thanks for pointing out to double check that.
1 user thanked ericschmidt for this useful post.
Remco on 6/20/2017(UTC)
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.039 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download