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

Notification

Icon
Error

Issues with NUnit async tests and SerialAttribute
chillitom
#1 Posted : Tuesday, June 30, 2015 8:47:13 AM(UTC)
Rank: Member

Groups: Registered
Joined: 4/1/2012(UTC)
Posts: 19

Thanks: 1 times
Was thanked: 3 time(s) in 3 post(s)
Hi There,

Seeing strange behaviour and think it can only be explained by NUnit async tests not obeying the Serial attribute (Both class and methods marked with the attribute).

Could someone outline the intended behaviour in this case? My expectation is that the task should run to completion before another begins.

Thanks, T.
Remco
#2 Posted : Tuesday, June 30, 2015 9:21:46 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for sharing this issue.

NUnit itself handles this under the hood (NCrunch doesn't call into the tests directly), but my understanding is that an async test should always be run to completion before the next one starts.

Note that this doesn't necessarily provide cover for other threads that are kicked off during the test run. If you have a test (async or otherwise) that launches another task and then returns before this task is complete, neither NCrunch or NUnit will know about the background thread in order to wait for it. This thread can then freely interfere with subsequent test runs in the process.

If adjusting your code to cater for such a scenario is too difficult (i.e. you can't get access to the Task management from the test code), using the IsolatedAttribute would probably solve this for you as NCrunch would just clean up the process and avoid re-using it. There will be some loss of performance involved in re-spawning the process after the test completes.
chillitom
#3 Posted : Monday, July 6, 2015 2:14:19 PM(UTC)
Rank: Member

Groups: Registered
Joined: 4/1/2012(UTC)
Posts: 19

Thanks: 1 times
Was thanked: 3 time(s) in 3 post(s)
Quick follow-up to say that Isolated worked as you suggested and led us to find an error in our code. Thanks for your help.
1 user thanked chillitom for this useful post.
Remco on 7/6/2015(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.025 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download