简体   繁体   中英

NUnit Testing of Individual Projects

I use NUnit 2.6.4 to test my code, but would like to switch to using something within Visual Studio 2017. I tried NUnitTestAdapter.WithFramework, but realized that clicking "Run All" (Tests) on Test Explorer windows will build my entire solution in an attempt to discover all tests, and not just build the test project I want. When I build only the project I want, Test Explorer will not discover my tests. http://nunit.org/nunitv2/docs/2.6.4/vsTestAdapter.html and https://github.com/Microsoft/vstest/issues/696 seem to imply that building the whole solution triggers the test discovery.

Is there a way to only discover tests of a specific project, like NUnit is able to do?

In Build menu > Configuration Manager, you can select which projects run in a certain configuration when you select Build menu > Build Solution or Test Explorer window > Run All. You can also add configurations in the manager. Thus, you can have "UnitTestsOfAlgorithms" , "UnitTestsOfDataTables" , and "IntegrationTestsOfStateMachine" , "Debug" , and "Release" configurations, all configured to build the parts of the solution about which different sections of your team care.

This is not an elegant solution for me, but necessary. It seems that you need to build all projects in the current configuration to trigger test discovery.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM