nunit3-vs-adapter: Tests using TestCaseSource will not run in adapter
Maybe this is more of a question, are they supposed to be able to run in VS Test Explorer?
I see the tests listed under “Not Run Tests” and they even display the value of the parameters in TestCaseSource. But seemingly no way to run them. I noticed they run fine with the console runner (dotnet test).
I do not have the VS extension adapter installed, running everything from nuget packages.
Barebones sample
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="NUnit" Version="3.6.1" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.6.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0-alpha1" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
</Project>
using System;
using NUnit.Framework;
namespace TestCaseSourceFails
{
[TestFixture]
public class Tests
{
[Test]
public void NormalTest()
{
Assert.Pass();
}
public static Guid GetRandomGuid()
{
return Guid.NewGuid();
}
private static readonly Guid Test1Guid = GetRandomGuid();
private static readonly Object[] RandomGuidSource = new Object[]
{
new Object[] { Test1Guid }
};
[TestCaseSource(nameof(RandomGuidSource))]
public void TestCaseSourceTest(Guid testGuid)
{
// never runs in vs test adapter
// but will run fine in console runner
Assert.Fail();
}
}
}
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 25 (17 by maintainers)
@Nicholi Yup!
We are not checking for null context at all there and we should. However, that will only give you a different error message, which isn’t much help.
I think this is fairly fundamental. What we did in the past was to create CUrrentCOntext on the fly if it was null. However, that leads to hard to understand errors, since the context can’t actually be initialized correctly. I made the decision to stop doing that and fix whatever came up as a result. Lots of stuff got fixed, in fact, but this is a new one.