2013-10-27 04:01:33 |
Charlie Poole |
description |
The following code works fine with NUnit test adapter (VS 2012, nunit 2.6.2):
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
public class AnyAttribute : ParameterDataAttribute
{
public override IEnumerable GetData(ParameterInfo parameter)
{
if (parameter.ParameterType == typeof(int))
{
return new[] { 122 };
}
else
{
return new[] { "a" };
}
}
}
public class Class1234
{
[Test]
public void ShouldBEHAVIOR([Any] int a, [Any] string b)
{
Assert.Fail("FAILED!");
}
}
But the following does not (although it works just fine in gui standalone nunit runner) and VS Test Runner marks the test as not run:
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
public class AnyAttribute : ParameterDataAttribute
{
public override IEnumerable GetData(ParameterInfo parameter)
{
if (parameter.ParameterType == typeof(int))
{
return new[] { 122 };
}
else
{
return new[] { "a" + new Random().Next() }; //______ONLY CHANGE________!
}
}
}
public class Class1234
{
[Test]
public void ShouldBEHAVIOR([Any] int a, [Any] string b)
{
Assert.Fail("FAILED!");
}
}
Best regards,
grzesiek |
[This bug is now tracked at https://github.com/nunit/nunit-vs-adapter/issues/15]
The following code works fine with NUnit test adapter (VS 2012, nunit 2.6.2):
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
public class AnyAttribute : ParameterDataAttribute
{
public override IEnumerable GetData(ParameterInfo parameter)
{
if (parameter.ParameterType == typeof(int))
{
return new[] { 122 };
}
else
{
return new[] { "a" };
}
}
}
public class Class1234
{
[Test]
public void ShouldBEHAVIOR([Any] int a, [Any] string b)
{
Assert.Fail("FAILED!");
}
}
But the following does not (although it works just fine in gui standalone nunit runner) and VS Test Runner marks the test as not run:
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
public class AnyAttribute : ParameterDataAttribute
{
public override IEnumerable GetData(ParameterInfo parameter)
{
if (parameter.ParameterType == typeof(int))
{
return new[] { 122 };
}
else
{
return new[] { "a" + new Random().Next() }; //______ONLY CHANGE________!
}
}
}
public class Class1234
{
[Test]
public void ShouldBEHAVIOR([Any] int a, [Any] string b)
{
Assert.Fail("FAILED!");
}
}
Best regards,
grzesiek |
|