I'm writing a decorator (to implement a Retry attributes for NUnit tests). Everything runs fine when executing with Telerik JustTest -- except:
* "Not Executed" is reported
* Stepping thru in debug, "Run" is never called
Using NUnit 2.6. I have read that Resharper has issues in this same area and there are workarounds. We run Nunit for deployment builds, and I would like to be able to run the tests in VS.
public class RetriedTestMethod : NUnit.Core.Test
{
private readonly int requiredPassCount;
private readonly int tryCount;
private readonly NUnit.Core.Test backingTest;
public RetriedTestMethod(NUnitTestMethod test, int tryCount, int requiredPassCount)
: base((TestName)test.TestName.Clone())
{ //executes in debug
backingTest = test;
this.tryCount = tryCount;
this.requiredPassCount = requiredPassCount;
}
private static bool TestFailed(TestResult result)
{
return result.ResultState == ResultState.Error || result.ResultState == ResultState.Failure;
}
public override TestResult Run(EventListener listener, ITestFilter filter)
{ //Never called
var successCount = 0;
TestResult failureResult = null;
for (var i = 0; i < this.tryCount; i++)
{
var result = backingTest.Run(listener, filter);
if (!TestFailed(result))
{
if (i == 0)
{
return result;
}
if (++successCount >= this.requiredPassCount)
{
return result;
}
}
else
{
failureResult = result;
}
}
return failureResult;
}
I attached the set of files with unit tests.