编写单元测试到组装或在单独的程序? [英] Write Unit tests into an assembly or in a separate assembly?
问题描述
在编写单元测试,你把你的测试,您希望测试或单独测试组件的组件内?我曾经在一个单独的汇编语言编写,在类的测试应用程序,便于deloyment,因为我可以排除组装。有谁要测试和若然是它的理由在组件中写有测试?
When writing unit tests, do you place your tests inside the assembly you wish to test or in a separate test assembly? I have written an application with the tests in classes in a separate assembly for ease of deloyment as I can just exclude the assembly. Does anyone write there tests within the assembly you wish to test and if so what is the justification for it?
推荐答案
我有一个接口的项目,一个项目的测试,域项目和数据项目的单一解决方案。当我松开我刚刚发布的接口,该接口犯规基准测试,以便它不以被编译
I have a single solution with an interface project, a tests project, a domain project and a data project. When i release i just publish the interface, which doesnt reference Tests so it doesnt get compiled in.
编辑:底线是真的,你不希望它是一部分你的最终版本。您可以通过使用一个单独的项目/组件VS自动实现这一目标。但是你可以把它在同一个程序集,但如果你使用恶性或MSBuild的然后就没有编译代码。有点乱,虽然,保持整洁,使用一个单独的程序:)
The bottom line is really that you dont want it to be part of your final release. You can achieve this automatically in VS by using a separate project/assembly. However you can have it in the same assembly, but then just not compile that code if you're using nant or msbuild. Bit messy though, keep things tidy, use a separate assembly :)
这篇关于编写单元测试到组装或在单独的程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!