Running xunit.net tests in VSTS
Just an update on this as I've recently also had this issue and couldn't get the VsTest runner to discover my .net Core 2.0 xunit tests.
Note: VsTest runner works fine locally on my machine, but not from VSTS - even though xunit test adapters are there.
In any case, use the .NET Core build task instead - it's pretty easy to use. Basically:
- Add .Net Core build task (preview atm)
- Select desired .NET Core version
- Change command to test
- Add path or paths to your test projects - e.g. **/*Tests.csproj
- Any additional arguments - e.g --filter "Category!=Integration"
- There's also a Publish test results option that'll create trx output file
I had the same issue once I made the switch to xUnit, after lots of trial-and-error and searching I found that the xUnit test runner can only be run in an assembly targeting .NET 4.5.2 or above, otherwise it cannot be loaded (and thus the tests will not be found).
The documentation is a bit vague here, since the Getting Started with xUnit guide doesn't really mention this, it only mentions to create a new class library project "targeting .NET 4.5.2 (or later)".
But this is only for the assembly containing the actual tests, your projects being tested can still target .NET 4.5. In my case I simply switched my test assemblies to target .NET 4.5.2, but all the other projects still target .NET 4.5 and it works very well.