All other tests work, and This test runs in VS Test runner, and in Resharper Test Runner. I have tried to provide enough information for reproduction of the issue. Sorry if it is too much.
I absolutely love NCrunch and have been a user for nearly 10 years at this point. Thank you for all the hard work and I appreciate any help I can get for this issue.
My version of NCrunch is 4.6.0.3 and is running in Visual Studio Pro 2019 Version 16.8.5
An error occurred while analysing this project after it was built: System.Exception: DiscoverRazorTests: Discovering in MyProject.MyTests.
GetSourceInformation(MyTests): Attempting to find source file
GetSourceInformation(MyTests): Verifying file = C:\{MyPath}\MyTests.razor
GetSourceInformation(MyTests): Source info found: File = C:\{MyPath}\MyTests.razor, LineNumber = 3
Error while discovering test 'MyProject.MyTests.RazorTests':System.NullReferenceException: Object reference not set to an instance of an object.
at nCrunch.Module.XUnit2.Integration.XUnitNCrunchDiscoveredTestContainer.convertTraitsToCategories(Dictionary`2 traits)
at nCrunch.Module.XUnit2.Integration.XUnitNCrunchDiscoveredTestContainer.StoreDiscoveredTest(ITestCase testCase, TestName testName)
at nCrunch.Module.XUnit2.Integration.XUnitDiscoveryMessageSink.discoverTest(ITestCase testCase)
at nCrunch.Module.XUnit2.Integration.XUnit2DiscoveryEnvironment.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, ComponentUniqueName testComponentUniqueName, PlatformType platformType, DynamicProxy[] dynamicProxies)
at nCrunch.TestExecution.TestFinder.<>c__DisplayClass0_2.<FindTestsForFrameworks>b__1()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.TestExecution.TestFinder.<>c__DisplayClass0_0.<FindTestsForFrameworks>b__0()
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)
MyProject.csproj
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<IsPackable>false</IsPackable>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="bunit" Version="1.0.0-preview-01" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="coverlet.collector" Version="3.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
_Imports.razor
@using Xunit
@using Bunit
@using AngleSharp.Dom
@using Bunit.TestDoubles
@using Microsoft.JSInterop
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.Extensions.DependencyInjection
MyTests.razor
@inherits TestComponentBase
<Fixture Test="NoErrorsDisplaysEmpty">
<ComponentUnderTest>
<h1>Hello World</h1>
</ComponentUnderTest>
@code {
public void NoErrorsDisplaysEmpty(Fixture fixture)
{
}
}
</Fixture>