Build/Test Issues

Analysis failure for generic fixture

Started by GreenMoose on 2,344 views

[NCrunch v4.3.0.13]
[NUnit v2.6.2]
[Bug Report Ref: D-1767]

After picking up an 1 year old legacy project, NCrunch fails to analyze 1 test project with error below:

NCrunch: This project was built on server '(local)'
NCrunch: The tests in this project were discovered on server '(local)'

An error occurred while analysing this project after it was built: System.NullReferenceException: Object reference not set to an instance of an object.
   at nCrunch.TestExecution.DiscoveredTestMember.GetDistributedCapabilities()
   at nCrunch.TestExecution.DefaultDiscoveredTestFactory.(FrameworkTest , ComponentUniqueName )
   at nCrunch.TestExecution.DefaultDiscoveredTestFactory.createTestsForFramework(Dictionary`2 discoveredTests, IEnumerable`1 tests, ComponentUniqueName testComponentUniqueName)
   at nCrunch.TestExecution.DefaultDiscoveredTestFactory.CreateDiscoveredTests(ReflectedAssembly assembly, IEnumerable`1 tests, ComponentUniqueName testComponentUniqueName)
   at nCrunch.TestExecution.TestFinder..()
   at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
   at nCrunch.TestExecution.TestFinder..()
   at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
   at nCrunch.TestExecution.TestFinder.FindTestsForFrameworks(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, DescribedTestFrameworkDiscoverer[] describedDiscoverers, ComponentUniqueName testComponentUniqueName, PlatformType platformType, DynamicProxy[] dynamicProxies)
   at nCrunch.TestExecution.RemoteTaskRunner.AnalyseAssembly(DescribedTestFrameworkDiscoverer[] applicableFrameworks, ComponentUniqueName testComponentUniqueName, PerfTracker perfTracker)


I have isolated it to a generic fixture, and NCrunch fails analysis when I have this fixture in the project, and succeeds if I remove the generic arguments:

    using NUnit.Framework;

    [TestFixture(TypeArgs = new[] { typeof(string) })]
    internal class SomeFixture<TOne>
    {
        [Test]
        public void SomeTest()
        {
        }
    }


Thanks.
FWIW: It does not help if I upgrade to NUnit 2.7.1, but issue resolves when upgrading to NUnit 3.0. Unfortunately v3.0 has some breaking changes in this solution that causes us to remain on NUnit v2 (Work of upgrading to v3 was started a long time ago but then halted due to the workload involved).

Edited

Good catch, thanks for sharing this! Does changing the framework utilisation type for NUnit allow you to work around the problem?
Changing to StaticAnalysis voids the error but the test will not run with error message below:

NCrunch was unable to locate this test during NUnit's execution run.  This problem can be caused by tests with names that contain random elements, such as through the use of NUnit's RandomAttribute.  Please ensure your test is named consistently or consider changing your 'Framework utilisation type for NUnit' solution-level configuration setting to 'StaticAnalysis'.


I have however for now replaced the type parmeters with derived fixtures to get work going since it was only 18 instances.

Edited

I'm having trouble reproducing the issue you've reported with this code:




    using NUnit.Framework;

    [TestFixture(TypeArgs = new[] { typeof(string) })]
    internal class SomeFixture<TOne>
    {
        [Test]
        public void SomeTest()
        {
        }
    }


I'm testing with NUnit V2. It seems to work without exception under both static and dynamic analysis. Can you confirm whether this precise code sample fails on your end with the exception? Is there anything else I should be taking into consideration?

Edited

I am using target .net framework v4.5, but it also failed with newer ones. I have reproed it on 2 computers, you can find a repro sample (289kB) here: https://gofile.io/?c=IZSuup
Could you try the following build and let me know if this solves the problem for you?

NCrunch_Console_4.4.0.3.msi
NCrunch_Console_4.4.0.3.zip
NCrunch_GridNodeServer_4.4.0.3.msi
NCrunch_GridNodeServer_4.4.0.3.zip
NCrunch_LicenseServer_4.4.0.3.zip
NCrunch_VS2008_4.4.0.3.msi
NCrunch_VS2010_4.4.0.3.msi
NCrunch_VS2010_4.4.0.3.zip
NCrunch_VS2012_4.4.0.3.msi
NCrunch_VS2012_4.4.0.3.zip
NCrunch_VS2013_4.4.0.3.msi
NCrunch_VS2013_4.4.0.3.zip
NCrunch_VS2015_4.4.0.3.msi
NCrunch_VS2015_4.4.0.3.msi.7z
NCrunch_VS2015_4.4.0.3.zip
NCrunch_VS2017_4.4.0.3.msi
NCrunch_VS2017_4.4.0.3.msi.7z
NCrunch_VS2017_4.4.0.3.zip
NCrunch_VS2019_4.4.0.3.msi
NCrunch_VS2019_4.4.0.3.msi.7z
NCrunch_VS2019_4.4.0.3.zip
Yes (incl. using UseDynamicAnalsys)! Thanks

Post a reply

Log in to reply.