删除发布版本的 NUnit 引用
我有一个包含许多 NUnit 测试的项目。我很高兴这些测试包含在调试配置构建中,但我想删除发布配置对 nunit.framework 的依赖。有没有办法排除特定(发布)配置的 NUnit 引用和 nunit 测试对象?我正在使用 Sharp Develop,但我很好奇您将如何使用 Visual Studio 解决这个问题。
有什么线索吗?
I have a project with many NUnit tests. I am happy for these tests to be included in the Debug configuration build but I would like to remove the dependency on nunit.framework for the Release configuration. Is there a way of excluding the NUnit reference and the nunit test objects for a specific (Release) configuration? I am using Sharp Develop but I am curious how you would approach this problem with Visual Studio as well.
Any clues?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
听起来您的测试与发布代码位于同一项目中。这不是一个好主意 - 将代码分成两个项目,一个包含测试,另一个包含生产代码。只有测试项目需要引用 NUnit。
这也意味着发布代码不会附带任何测试,并且仅浏览生产代码或仅测试代码会更容易。
It sounds like you've got your tests in the same project as your release code. That's not a great idea - split the code into two projects, one with the tests and one with the production code. Only the test project will need to refer to NUnit.
That also means that none of the tests will ship with the release code, and it's easier to browse just the production code or just the test code.
如果您更喜欢将我的单元测试作为您要测试的项目的一部分进行开发,则可以将以下条件添加到您的单元测试文件和项目文件中的 nunit 引用中。
当您处于调试模式时,这将仅包括 nunit 引用以及构建中的测试类。
所以你的项目文件可能有这样的内容:
If you prefer to develop with my Unit Tests as a part of the project you're trying to test, you can add the following condition to both your unit test files and your nunit reference in the project file.
That will only include the nunit reference as well as your test classes in the build when you're in debug mode.
So your project file might have something like this:
将单元测试移至不同的程序集 - 即 YourProject.UnitTests
这不会构成部署包的一部分,并且无需在主应用程序中包含 nUnit 引用。
Move your unit tests to a different assembly - i.e. YourProject.UnitTests
This won't form part of your deployment package, and there will be no need to include the nUnit reference in your main application.