Reputation: 5260
Test class
[TestFixture]
public class Class1
{
[Test]
public void testtesttest()
{
Assert.IsTrue(true);
}
}
Dependencies
I followed instructions from here.
Why can't I discover my unit tests?
Upvotes: 1
Views: 1306
Reputation: 5260
.NET Core Solution
It turns out I had to have a unit test project instead of a class library:
I also followed instructions from the MSDN website here.
I was running the following in a command prompt to make sure I had the unit test template:
dotnet new -i NUnit3.DotNetNew.Template
My NuGet Packages Dependencies
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.2.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.2.0" />
<PackageReference Include="NUnit" Version="3.8.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
</ItemGroup>
Update
As @Lexli pointed out, you don't need the MSTest packages if you are only going to use NUnit tests.
However, make sure you use .NET Core and not .Netcore Standard. The .NET Core comes with the Microsoft.netCore.App SDK which is needed for running unit tests. Unit tests can't be run with .NET standard class libraries.
In projects where the .NET framework was v4.0 I had to use NUnit version 3.0 - anything higher and the project wasn't discovered.
Try clearing temporary files located in the %TEMP% directory.
Note: This path is generally at C:\Users\(yourusername)\AppData\Local\Temp
Upvotes: 5