简体   繁体   中英

Does Visual Studio compile test classes into an assembly?

Does Visual Studio compile classes marked with test attributes into an assembly? Suppose this assembly has internal classes that could benefit from unit test coverage.

Assuming you've got a separate test project, yes that's really just another class library project. (If you're expecting VS to split classes from a single project into "test" and "non-test" assemblies, then the answer is no... and you shouldn't do that :)

Unit testing internal classes is entirely reasonable - and is by far the most important reason for InternalsVisibleToAttribute . You make your production internal classes visible to your test project, and then you can test them.

Yes. More specifically, Visual Studio takes the classes contained within a test project and generates a DLL via the compilation process.

If you create a separate test project, it will get compiled into a different assembly from the main project. Often, the test project just gets ignored when you deploy so the client will never see it. One good way to wrap your mind around it is to try:

> vstest.console MyTestProject\bin\Debug\MyTestProject.dll

The test runner only picks up the test assembly.

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