我如何 运行 在我的构建中测试应用程序项目,而不是测试项目?

How can I run tests in my build that are under the application project, not a test project?

我继承了为解决方案创建构建的乐趣,该解决方案在应用程序项目中有测试文件,而不是在测试项目中。

MySolution 
    |__MyProject
          |__MyClass.cs
          |__MyClassTest.cs

我之前创建的所有构建都有一个测试项目,并且可以很好地处理 VSTS 中的测试任务。由于没有测试程序集,因此不会选择测试 运行。

我在构建步骤中尝试将项目程序集作为 "test assembly",但这没有用。我怎样才能做到这一点?

编辑

这是指向程序集的日志。

2018-07-31T18:31:25.0890193Z Starting test execution, please wait...
2018-07-31T18:31:25.8549638Z NUnit Adapter 3.10.0.21: Test execution started
2018-07-31T18:31:25.8558752Z Running all tests in C:\agent\_work\s\MyProject\bin\MyProject.dll
2018-07-31T18:31:26.8625176Z NUnit couldn't find any tests in C:\agent\_work\s\MyProject\bin\MyProject.dll
2018-07-31T18:31:26.9532542Z Running all tests in C:\agent\_work\s\MyProject\obj\Release\Before-PostSharp\MyProject.dll
2018-07-31T18:31:26.9539232Z NUnit couldn't find any tests in C:\agent\_work\s\MyProject\obj\Release\Before-PostSharp\MyProject.dll
2018-07-31T18:31:26.9691860Z Running all tests in C:\agent\_work\s\MyProject\obj\Release\MyProject.dll
2018-07-31T18:31:26.9692255Z NUnit couldn't find any tests in C:\agent\_work\s\MyProject\obj\Release\MyProject.dll
2018-07-31T18:31:26.9726008Z NUnit Adapter 3.10.0.21: Test execution complete

无论这是测试 assemble 还是其他可执行文件,测试都有效。当某些东西在测试中无法解决问题时,第一步是检查它是否在 Visual Studio 中工作,接下来是深入研究 VSTS 配置。 @Yatrix 确认它也没有在他的 Visual Studio 上工作,所以我在 https://github.com/OsirisTerje/ExecutableAsTest 上推了一个重现项目,从那个 @yatrix 注意到他正在使用 NUnit 2.6.4 和 NUnit 3.10 适配器。 NUnit 2 和 NUnit 3 测试框架非常不同,使用不同的相应适配器。 运行 NUnit 2 适配器,@yatrix 报告它现在可以工作了。