Racer Feature Focus – Using Attributes

In the last PDC Microsoft shown a new tool called Chess (http://channel9.msdn.com/pdc2008/TL58/) that will help the user find Concurrent bugs. Unfortunately Chess is still a Microsoft Research project and until it will become an actual product the only product that can deterministically find deadlock issues is Racer.

Software developers that don’t want to wait until Chess comes out can use the latest Racer feature – Attribute support.

  • Use ParallelInspection attribute to define a multithreaded test instead of the ThreadTest class.
  • Use ScenarioTimeout, TestTimeout and OnNumberOfThreads attributes instead of methods with the same name.
  • Use the Unit Testing framework’s Setup and TearDown methods instead of ThreadTest.ScenarioSetup and ThreadTest.ScenarioTearDown.
    • Only supported for MSTest & NUnit for now.

 

And so the following code:

[Test]
public void TestUsingOldInterface()
{
ThreadTest
.ScenarioSetup(() => i = 0)
.ScenarioTearDown(() => Assert.AreEqual(i, 2))
.AddThreadAction(delegate
{
lock (syncObject1)
{
lock (syncObject2)
{
i++;
}
}
}
)
.OnNumberOfThreads(2)
.Timeout.PerScenario(1000)
.Timeout.PerTest(10000)
.Start();
}

 

Will look like (using NUnit):

[SetUp]
void ScenarioSetup()
{
i = 0;
}

[TearDown]
void ScenarioTearDown()
{
Assert.AreEqual(i, 2);
}

[Test, ParallelInspection(OnNumberOfThreads = 2, ScenarioTimeout = 1000, TestTimeout = 10000)]
public void TestUsingAttributes()
{
lock (syncObject1)
{
lock (syncObject2)
{
i++;
}
}
}
TOP