Build/Test Issues

TestCase attribute messing up NCrunch entirely

Started by anilkamath on 7,551 views

When i have a test with the TestCase attribute Ncrunch fails to run any of the tests. here is the error that is seen


[17:03:46.1891-TestExecutionTask-13] ERROR (Internal): System.Reflection.CustomAttributeFormatException: 'Result' property specified was not found. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
--- End of inner exception stack trace ---
at System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit)
at System.Reflection.RuntimeMethodInfo.GetCustomAttributes(Boolean inherit)
at NUnit.Core.Reflect.GetAttributes(ICustomAttributeProvider member, Boolean inherit)
at NUnit.Core.Reflect.HasAttribute(ICustomAttributeProvider member, String attrName, Boolean inherit)
at NUnit.Core.Reflect.GetMethodsWithAttribute(Type fixtureType, String attributeName, Boolean inherit)
at NUnit.Core.NUnitTestFixture..ctor(Type fixtureType, Object[] arguments)
at NUnit.Core.Builders.NUnitTestFixtureBuilder.BuildSingleFixture(Type type, Attribute attr)
at NUnit.Core.Builders.NUnitTestFixtureBuilder.BuildFrom(Type type)
at NUnit.Core.Extensibility.SuiteBuilderCollection.BuildFrom(Type type)
at NUnit.Core.TestFixtureBuilder.BuildFrom(Type type)
at NUnit.Core.Builders.TestAssemblyBuilder.GetFixtures(Assembly assembly, String ns)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)
at NUnit.Core.TestSuiteBuilder.Build(TestPackage package)
at NUnit.Core.SimpleTestRunner.Load(TestPackage package)
at nCrunch.TestExecution.Frameworks.NUnit.NUnitTestFramework.InitialiseFrameworkForExecution(String solutionDirectory, String testAssemblyPath, Int32 defaultTimeout)
at nCrunch.TestExecution.RemoteTestRunner.#=qn1yXL7OMLYnsnvw4beLiAAeJO1e0Wb0wyJoMYaKZ6Hs=(Type #=qwigHKwK_oJMjwQiNaa0kBGZ1T2uFgas3$$xtOpakwe8=)
at nCrunch.TestExecution.RemoteTestRunner.RunTests(IMasterExecutionMap[] masterExecutionMaps, IList`1 testsToRun)


This is what my test looks like:

[TestCase(2, Description = "SquareOf2", Result = 4)]
[Test]
public int ShouldRoundTaxToNearest05(decimal valueToBeSquared)
{
return obj.Square(valueToBeSquared);
}

From the error it seems its not able to pick up the Result attribute correctly.

FYi if i comment out TestCase line everything works smoothly..

Let me know if you need any more clarifications.


P.S: Awesome tool but please make it a little faster especially on solutions with 20+ projects

Edited

Thanks for reporting this one. This is a problem caused by the instrumentation messing with named attribute parameters (i.e. the 'Result' named attribute parameter on TestCase), and is on the list of known issues to be fixed in a future version.

If you're having trouble getting NCrunch to run quickly on a large solution, I recommend having a look at the documentation around this area. You'll find that your experience with NCrunch has far more to do with the tests you are running and the chunkiness of your projects as opposed to the number of projects involved. In fact, NCrunch usually works much better on solutions with large numbers of small projects, as it has more opportunities to optimise the build process.
The fix for the above problem has now been released as part of 1.36b.

Post a reply

Log in to reply.