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

Notification

Icon
Error

Test with Threads wont pass
albertomonteiro
#1 Posted : Monday, February 9, 2015 4:26:16 AM(UTC)
Rank: Member

Groups: Registered
Joined: 5/28/2012(UTC)
Posts: 17
Location: Fortaleza, Ceara - Brasil

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

I am working on this Project: https://github.com/jjrdk/ArchiMetrics
When running test from class "PrioritySchedulerTests" with Test Explorer in VS 2013, all tests work fine.
But if I run using NCrunch, they doesnt pass.

I get following error:

An exception was thrown in the Task Environment: System.Threading.ThreadInterruptedException: O thread foi interrompido por um estado de espera.
em System.Threading.Monitor.ObjWait(Boolean exitContext, Int32 millisecondsTimeout, Object obj)
em System.Threading.Monitor.Wait(Object obj, Int32 millisecondsTimeout, Boolean exitContext)
em System.Threading.SemaphoreSlim.WaitUntilCountOrTimeout(Int32 millisecondsTimeout, UInt32 startTime, CancellationToken cancellationToken)
em System.Threading.SemaphoreSlim.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
em System.Collections.Concurrent.BlockingCollection`1.TryTakeWithNoTimeValidation(T& item, Int32 millisecondsTimeout, CancellationToken cancellationToken, CancellationTokenSource combinedTokenSource)
em System.Collections.Concurrent.BlockingCollection`1.<GetConsumingEnumerable>d__0.MoveNext()
em ArchiMetrics.Common.PriorityScheduler.<.ctor>b__1() na D:\Projetos\ArchiMetrics\ArchiMetrics.Common\PriorityScheduler.cs:linha 44
em System.Threading.ThreadHelper.ThreadStart_Context(Object state)
em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
em System.Threading.ThreadHelper.ThreadStart()
System.Threading.ThreadInterruptedException: O thread foi interrompido por um estado de espera.
em System.Threading.Monitor.ObjWait(Boolean exitContext, Int32 millisecondsTimeout, Object obj)
em System.Threading.Monitor.Wait(Object obj, Int32 millisecondsTimeout, Boolean exitContext)
em System.Threading.SemaphoreSlim.WaitUntilCountOrTimeout(Int32 millisecondsTimeout, UInt32 startTime, CancellationToken cancellationToken)
em System.Threading.SemaphoreSlim.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
em System.Collections.Concurrent.BlockingCollection`1.TryTakeWithNoTimeValidation(T& item, Int32 millisecondsTimeout, CancellationToken cancellationToken, CancellationTokenSource combinedTokenSource)
em System.Collections.Concurrent.BlockingCollection`1.<GetConsumingEnumerable>d__0.MoveNext()
em ArchiMetrics.Common.PriorityScheduler.<.ctor>b__1() na D:\Projetos\ArchiMetrics\ArchiMetrics.Common\PriorityScheduler.cs:linha 44
em System.Threading.ThreadHelper.ThreadStart_Context(Object state)
em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
em System.Threading.ThreadHelper.ThreadStart()
An exception was thrown in the Task Environment: System.ArgumentNullException: Valor não pode ser nulo.
em System.Threading.SemaphoreSlim.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
em System.Collections.Concurrent.BlockingCollection`1.TryTakeWithNoTimeValidation(T& item, Int32 millisecondsTimeout, CancellationToken cancellationToken, CancellationTokenSource combinedTokenSource)
em System.Collections.Concurrent.BlockingCollection`1.<GetConsumingEnumerable>d__0.MoveNext()
em ArchiMetrics.Common.PriorityScheduler.<.ctor>b__1() na D:\Projetos\ArchiMetrics\ArchiMetrics.Common\PriorityScheduler.cs:linha 44
em System.Threading.ThreadHelper.ThreadStart_Context(Object state)
em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
em System.Threading.ThreadHelper.ThreadStart()
System.ArgumentNullException: Valor não pode ser nulo.
em System.Threading.SemaphoreSlim.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
em System.Collections.Concurrent.BlockingCollection`1.TryTakeWithNoTimeValidation(T& item, Int32 millisecondsTimeout, CancellationToken cancellationToken, CancellationTokenSource combinedTokenSource)
em System.Collections.Concurrent.BlockingCollection`1.<GetConsumingEnumerable>d__0.MoveNext()
em ArchiMetrics.Common.PriorityScheduler.<.ctor>b__1() na D:\Projetos\ArchiMetrics\ArchiMetrics.Common\PriorityScheduler.cs:linha 44
em System.Threading.ThreadHelper.ThreadStart_Context(Object state)
em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
em System.Threading.ThreadHelper.ThreadStart()

Remco
#2 Posted : Monday, February 9, 2015 4:35:12 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 932 times
Was thanked: 1259 time(s) in 1172 post(s)
Hi, thanks for sharing this issue.

NCrunch's support for MSTest is emulated rather than integrated. While the implementation is intended to be as close as possible to MSTest, there are always some things that are handled differently.

It looks to me that in this case you have a test that is throwing exceptions on a background thread. MSTest is probably swallowing these exceptions where NCrunch is reporting them as a test failure.

Multi-threaded behaviour in code under test can also have some unintended consequences if the lifespan of background threads is not correctly synchronised with the foreground test thread. This is not a problem specific to NCrunch, but it may manifest more often under NCrunch as the tests will be run much more frequently. See http://www.ncrunch.net/documentation/considerations-and-constraints_multi-threaded-tests for more details on this.
1 user thanked Remco for this useful post.
albertomonteiro on 2/9/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.041 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download