Rank: Member
Groups: Registered
Joined: 12/4/2013(UTC) Posts: 26 Location: New Zealand
Thanks: 2 times Was thanked: 3 time(s) in 3 post(s)
|
We would like to use the ExclusivelyUsesAttribute to prevent some issues with parallel execution of some legacy code. However, there appears to be a bug in this feature (NCrunch 1.48.0.5) when a colon is present in NUnit TestCase data. Below is a test that reproduces the issue. The tests should all run in parallel, but the test named "broken" does not pick up the ExclusivelyUsesAttribute. You can verify this by adding the "Exclusively Used Resources" column to the NCrunch Tests window. Code:
using System;
using System.Threading;
using NCrunch.Framework;
using NUnit.Framework;
//Copied directly from the NCrunch documentation
namespace NCrunch.Framework
{
public abstract class ResourceUsageAttribute : Attribute
{
private readonly string[] _resourceNames;
public ResourceUsageAttribute(params string[] resourceName)
{
_resourceNames = resourceName;
}
public string[] ResourceNames
{
get { return _resourceNames; }
}
}
public class ExclusivelyUsesAttribute : ResourceUsageAttribute
{
public ExclusivelyUsesAttribute(params string[] resourceName)
: base(resourceName) { }
}
}
namespace Demo
{
[TestFixture]
[ExclusivelyUses("Everything")]
public class Class1
{
Mutex _testRunning = new Mutex(false, "TestLock");
[SetUp]
public void NewTestStarted()
{
if (!_testRunning.WaitOne(0))
throw new InvalidOperationException("There should only be one test running at a time.");
}
[TearDown]
public void TestCompleted()
{
_testRunning.ReleaseMutex();
}
[TestCase("okay","a")]
[TestCase("okay", "b")]
[TestCase("okay", "c")]
[TestCase("okay", "d")]
[TestCase("d", "cmkds:", TestName = "broken")]
public void AllTestsShouldRunInSeries5(string dummy, string dummy2)
{
Thread.Sleep(3000);
}
}
}
|