我创建了一个针对.NET Framework 4.6.1的单元测试项目.测试显示在Test Explorer中,并在Visual Studio 2017中正常运行.
我想建立一个构建过程,所以我想从命令行运行测试.我试图使用mstest,但是没有找到测试.
当我跑
mstest /testcontainer:mp.tests\bin\debug\mp.tests.dll
Run Code Online (Sandbox Code Playgroud)
我明白了......
Loading messageparser.tests\bin\debug\messageparser.tests.dll...
Starting execution...
No tests to execute.
Run Code Online (Sandbox Code Playgroud)
但是我可以成功使用命令'dotnet test'来运行它们.
我跑的时候
dotnet test
Run Code Online (Sandbox Code Playgroud)
我明白了......
Build started, please wait...
Build completed.
Test run for C:\MP.Tests\bin\Debug\MP.Tests.dll(.NETFramework,Version=v4.6.1)
Microsoft (R) Test Execution Command Line Tool Version 15.5.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Total tests: 70. Passed: 70. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 8.2833 Seconds
Run Code Online (Sandbox Code Playgroud)
然而,我发现的指导建议"dotnet test"应该用于.NET Core而不提及.NET Framework.
dotnet测试是否适合从.NET Framework项目的命令行运行测试?或者我应该使用mstest?如果是这样,我该如何让它工作?