NUnit 和 NAnt 的未来考虑因素
在 .NET v1 期间,我曾尝试说服同事使用 NUnit 和 NAnt 的附加工具养成测试驱动和自动化构建的工作习惯,但没有取得多大成功。 当 .NET Framework 2.0 和 Visual Studio 2005 Team Suite 出现时,我能够“强制”我的团队编写测试并在 Visual Studio 中为自己提供可视化测试。 我还能够使用额外的 MSBuild 任务来调整项目文件,以执行更多的构建自动化。
当然,这并不意味着微软已经交付了完美的系统,但我相信他们已经采取了正确的步骤。 通过将所有这些功能直接融入到框架和产品中并成为“本机”,可以更轻松地推动开发人员进行更好的开发实践。
我早已忘记了开源选项(我确实怀念),我想知道 NUnit 和 NAnt 当前的版本持有什么价值主张? 在现阶段,可以通过哪些案例来说服团队不使用 MSBuild 或 MSTest?
澄清: 我的公司是纯粹的 Microsoft SI。 Visual Studio Team Suite版本、Database Professional版本、TFS等可供我们使用。 我们不使用 Visual Studio Professional 版本或更低版本。
During .NET v1 days, I have tried without much success to convince colleagues to develop test-driven and automated-build work habits using the additional tools of NUnit and NAnt. When .NET Framework 2.0 and Visual Studio 2005 Team Suite came into picture, I was able to "force" my team into writing tests and provide themselves with visual testing right inside Visual Studio. I was further able to tweak project files with extra MSBuild tasks to carry out more build automation.
Of course this does not mean Microsoft has delivered perfect systems, but I believe they have taken these in the correct steps forward. With all these features baked right into the framework and products and becoming "native" it got abit easier to motion developers into better development practices.
Having long forgotten the open-source options (which I do miss), I am wondering what value proposition do the current incarnations of NUnit and NAnt hold? What case can one argue at this stage to convince a team not to use MSBuild or MSTest?
Clarification:
My company is a pure Microsoft SI. Visual Studio Team Suite editions, Database Professional edition, TFS, and the like are available for our use. We do not use Visual Studio Professional edition or lesser.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MSBuild 是一个非常好的构建工具。 我已经将它与 NAnt 和 Cruisecontrol.Net 结合使用了几次。 NAnt 与 NAnt contrib 扩展一起在处理 NUnit、NCover 等 OSS 工具方面似乎更加灵活,而 MSBuild 可以构建 VS 解决方案这一事实是它的一大优势。 我发现创建构建脚本的最简单方法是同时使用 NAnt 来调用构建的不同部分(构建、fxcop、测试、覆盖率等)和 MSBuild 来执行实际构建。
关于 MSTest 我没什么好说的。 例如在构建服务器上安装既缓慢又麻烦。 它不是很灵活,并且具有各种“附加功能”,似乎更适合集成测试而不是单元测试。 我发现轻量级 XUnit.Net、MBUnit 或 NUnit 更适合单元测试。 速度在这里很重要,您希望经常运行测试,以便快速反馈代码更改的效果。 便携性也很重要。 您希望让测试在任何地方运行,而无需进行大量设置和黑客攻击,就像在未安装团队系统的计算机上需要 MSTest 一样。 尽管单元测试并不新鲜,但仍有大量开发正在进行。 最佳实践发生了很大变化,工具也发生了很大变化。 我不想受制于 Visual Studio 每隔几年才升级一次的工具。 三个 OSS .net 单元测试工具中的每一个都被设置为可扩展的。 MSTest 不是(据我所知)。
MSBuild is a pretty good build tool. I've used it in combination with NAnt and Cruisecontrol.Net a couple of times. NAnt together with the NAnt contrib extensions seems a bit more flexible in handling OSS tools like NUnit, NCover etc while the fact that MSBuild can build VS solutions is a big plus for it. I found the easiest way to create build scripts is to use both, NAnt to call the different parts of the build (build, fxcop, test, coverage etc) and MSBuild to do the actual building.
I haven't got much good to say about MSTest. It's slow and cumbersome to install on for example a build server. It's not very flexible and has all kinds of 'extras' that seem more geared to integration testing than unit testing. I found light weight XUnit.Net, MBUnit or NUnit to be far better suited for unit testing. Speed is important here, you want to run the tests often for quick feedback on the effects of your changes in code. Portability is important too. You want to have the tests run everywhere without a lot of setup and hacking like you need for MSTest on a machine that doesn't have team system installed. Although Unit testing isn't new there's still a lot of development going on there. Best practices change a lot and so do the tools. I don't want to be tied to a tool that only gets upgraded every few years with visual studio. Every one of the three OSS .net unit testing tools is set up to be extensible. MSTest isn't (as far as i've seen).
在我看来,NUnit 是 .NET 中单元测试的事实上的标准。 它是免费的,您可以在任何版本的 Visual Studio 中轻松编写测试。 如果 MS 在 VS 2005 Pro 中提供 MS Test(就像在 VS 2008 Pro 中那样),它现在可能已经接管了 - 但我认为为时已晚。
我认为 ReSharper 对于 Visual Studio 来说基本上是必不可少的,其中包括一个与 NUnit 配合良好的优秀测试运行器。 如果我正在开发一个开源项目,为什么我需要 VS 2008 Pro 或 VS 2005 Team Suite?
MSBuild 与 NAnt 略有不同,因为 MSBuild 与框架或 SDK 捆绑在一起(我现在不记得是哪一个) - 但我认为 NAnt 是一个更愉快的工作环境。MSBuild 显然更适合做原始“构建解决方案”位 - 但您可以从 NAnt 调用它。
In my view NUnit is the de facto standard for unit tests in .NET. It's free and you can easily write tests in any edition of Visual Studio. If MS had made MS Test available in VS 2005 Pro (as they have in VS 2008 Pro), it might have taken over by now - but I think it's too late.
I view ReSharper as basically essential for Visual Studio, and that includes a great test runner which works very well with NUnit. If I'm developing an open source project, why would I want to require VS 2008 Pro or VS 2005 Team Suite?
MSBuild vs NAnt is slightly different, as MSBuild is bundled with either the framework or the SDK (I can't remember which now) - but I think NAnt is a more pleasant environment to work in. MSBuild is clearly better for doing the raw "build the solution" bit - but you can invoke it from NAnt.