问题
I'm trying to create a release pipeline in VSTS that runs my xUnit-tests as specified in a Test Plan
.
Long story short: I can't get it to work.
What I'm using:
- Azure DevOps (formerly VSTS)
- Visual Studio Test task (v2.*)
- Test project targeting .NET Core 2.1
- xunit 2.4 with xunit.runner.visualstudio 2.4
In Azure DevOps I defined a Test Plan
that contains a Test Suite
which contains a Test
that has an Associated Automation
which points to my xUnit test.
I had to use the REST API to link the test code to the Test
as described here.
I can select that Test
in the visual designer for the VSTest task.
When I run the release pipeline the VSTest task fails with the following error message:
DiscoveryMessage : System.IO.FileNotFoundException: Unable to find tests for D:\a\r1\a\Foo.Tests.dll. Make sure test project has a nuget reference of package "Microsoft.NET.Test.Sdk" and framework version settings are appropriate. Rerun with /diag option to diagnose further.
The path to the Foo.Tests.dll is correct, all required files are copied as well.
- I explicitly specified the framework version in a
.runsettings
file (as the optionOther console options
doesn't work when using theTest plan
option). - Specified the
path to custom test adapters
- used
Visual Studio 2017
andInstalled by Tools Installer
options - Added a
.NET Core Tool installer
to install the correct .NET Core SDK - ...and any other combination of settings I could think of.
The error message is still the same.
Any ideas what I might be missing? Your help would be greatly appreciated at this point!
回答1:
After several more hours we stumbled across a web page that stated that you don't have to copy the binaries of your test project as input for the VSTest task but PUBLISH it instead. That never came to mind as vstest.console.exe
runs smoothly when you point it at the binaries on a local machine.
UPDATE: We had to add a Publish Artifact task at the end of our Build Pipeline and make the Release Pipeline pick up the published artifact.
来源:https://stackoverflow.com/questions/52588772/vstest-task-not-running-net-core-2-1-xunit-tests-from-test-plan