I have a solution build that produces outputs among which are a unit test assembly.
I have tried both the VsTest and the dotnet test pipeline tasks to run tests in this assembly. Every combination of arguments I can think of yields (paths anonymised):
Unable to find MyProject\MyTests.deps.json. Make sure test project has a nuget reference of package "Microsoft.NET.Test.Sdk".
It does have a reference to Microsoft.NET.Test.Sdk. What do I have to do to make it work?
I have tried:
dotnet test
only accepts .csproj and doesn't recognise dlls at alldotnet vstest
produces the error message mentioned above. I've tried the /Framework:.NETCoreApp,Version=v2.1 command line argument, matching the version of the assembly, which doesn't make any difference- VsTest task with and without the above argument. Again no difference.
Edit: I realised I had neglected to include the *.deps.json files in the build artefacts. Supplying these has produced a new error:
Unable to find MyProject\testhost.dll. Please publish your test project and retry.
What?
Edit #2: I've published the .csproj in the related build pipeline and run a subsequent step to copy everything from the resulting folder to the build artefacts. This doesn't make any difference.
How can this be so difficult?
Edit #3: To explain more clearly, what I am trying to achieve is to run SpecFlow tests, written in a .net core assembly, during my release pipeline. I can't run them in a build pipeline because they are integration tests that exercise deployed artefacts, and those artefacts haven't been deployed until the end of the release pipeline. I don't think I can do the pattern explained here because the release artefacts are compiled project outputs and the code isn't in scope anymore.
Why can't I just run tests from an assembly like Visual Studio does? These tests work fine in VS2017 and VS2019.