VSTS build of .NET Core 1.0 VSTest Warning: No tes

2019-05-05 19:13发布

I recently switched all of my unit tests over from xunit to mstest, and on my local dev machine everything works great, but when I try to run my tests using a CI build in VSTS, it doesn't recognize any tests in my test dll, stating:

"Warning: No test is available in c:\vsts_work\4\s\test\UnitTests\bin\Release\net452\UnitTests.dll".

I believe I have all of the important project.json bits in place:

  "testRunner": "mstest",

  "dependencies": {
    "dotnet-test-mstest": "1.0.1-preview",
    "MSTest.TestFramework": "1.0.1-preview"
  }

Of note, I am using an on-premise build agent, but I've proven I can log into that build agent using the service account under which the agent runs, and I can open visual studio and run the tests that way.

Also, while one could contrive it by looking at the above path, it is worth explicitly noting that I'm using the full framework.

Hoping someone out there has already conquered this one.

3条回答
地球回转人心会变
2楼-- · 2019-05-05 19:30

I figured out how to use the "Visual Studio Test" action, thanks to this stackoverflow post

The only thing that answer lacks is how to make it work in VSTS (the answer provides the command line). To get it to work in VSTS, I put the following string in the "Test Assembly" parameter

**\test\**\project.json

And then put the rest of the command line arguments under "Advanced Execution Options" in the "Other console options" box.

/UseVsixExtensions:true /logger:trx

Hope this helps the next guy who is trying to stick with the visual studio tooling.

查看更多
唯我独甜
3楼-- · 2019-05-05 19:36

I had a similar problem, getting the "Warning: No test is available" issue when I was looking right at the tests in Visual Studio. It turns out the tests were trying to run in x86 when the application is 64 bit.

I recommend going to the Test menu at the top of Visual Studio, and open

Test>Test Settings>Default Processor Architecture>

and make sure the tests are on the right architecture, if you have a similar problem and the other answers aren't helping.

查看更多
倾城 Initia
4楼-- · 2019-05-05 19:42

To run a .NET Core test during the build, you can add a "Command Line" task to run "dotnet test" command and set the "Working Folder" to the path where the "project.json" file placed: enter image description here

查看更多
登录 后发表回答