用于运行多个测试程序集的 NAnt 脚本
我刚刚进入 TDD,环顾四周,普遍的共识似乎是从代码项目到测试项目有一对一的映射。我的问题是,如果您遵循此路线,并且有多个测试程序集,那么将它们作为 NAnt 脚本的一部分运行的最佳方法是什么?如果有影响的话,我将使用 NUnit 作为我的测试框架。
I'm just getting into TDD, and from looking around, the general concensis seems to be to have a one to one mapping from a code project to a test project. My question is, if you follow this route, and have multiple test assemblies, what is the best way to run these as part of an NAnt script? If it makes a difference, I am using NUnit as my testing framework.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过 NUnit GUI 创建“测试项目”,并将其保存到文件中。在 GUI 中,您可以将测试 dll 添加到项目中,而测试 dll 又会引用正在测试的 dll。
然后,您可以从 NAnt 内将该文件传递到 NUnit 控制台。例如
,这样,NAnt 不需要知道测试 dll,只需要知道包含该信息的 NUnit 项目。
You can create a "test project" via the NUnit GUI, and save it to a file. In the GUI, you can add to the project the test dlls, which in turn reference the ones under test.
You can then pass that file to the NUnit console from within NAnt. e.g.
This way, NAnt need not know about the test dlls, just the NUnit project that contains that information.
我建议最好的方法是使用引用每个项目文件 (csproj) 的 CSC 命令而不是解决方案,从 NAnt 单独编译两个项目。然后使用 nunit-console 命令(作为单独的 Nant 任务)来执行测试。
无论您是构建一个大型脚本/文件来执行此操作,还是为每个项目或任务单独创建一个脚本/文件,都取决于您(或者您的项目有多复杂)。
我设置团队构建的方式是,我有一个“主”构建脚本,它调用其他构建脚本来执行特定任务。例如,“master”调用“compile”,然后调用“test”(适当地传递“compile”脚本的结果)。这样我的核心项目的编译就与自动化测试分开了。
I'd suggest the best way to go about this is to compile both projects from NAnt individually using the CSC command referencing each project file (csproj) rather than the solution. Then use the nunit-console command (as a separate Nant task) to execute your tests.
Whether you have one build large script/file that does this or separate separate ones for each project or task is up to you (or how complex your projects are).
The way I have my team's builds set up is that I have one 'master' build script which calls into other build scripts to perform specific tasks. For example 'master' calls 'compile' and then 'test' (passing in the results of the 'compile' script appropriately). This way the compilation of my core project is separated from the automated testing.