nunit-console 的无阴影选项
我有以下问题: 使用 /noshadow 选项运行 nunit-console 的优点和缺点是什么? 您的评论将会非常有帮助 谢谢
I have following question :
what are advantages and disadvantages in running nunit-console with /noshadow option?
Your comments will be very helpful
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现 /noshadow 的主要问题是它会阻止您的项目构建,因为 NUnit 现在被迫使用并锁定您的 DLL。如果禁用此选项,NUnit 将创建 DLL 的副本。
如果你尝试实践 TDD 并不断在红、绿、重构周期中构建项目,那么你不能轻易使用 /noshadow。您将收到如下错误消息:
可能有办法解决这个问题,但这是我发现的主要问题。
至于你什么时候会使用它:我认为主要原因是为了提高性能,但由于大多数真正的单元测试运行得非常快,我不确定你什么时候真正需要它。我相信其他人会想出一些很好的例子。
The main issue I've found with /noshadow is that it stops your project from building as NUnit is now forced to use and lock your DLL. If you leave this option disabled, then NUnit creates a copy of your DLL.
If you are trying to practice TDD and are constantly building the project in the Red, Green, Refactor cycle, then you can't easily use /noshadow. You will get an error message like:
There are probably ways around this, but that's the main problem I've found.
As for when you would use this: I think the main reason is to speed up performance, but as most true unit tests run really quickly, I'm not sure when you would really need this. I'm sure other people will come up with some good examples.
如果您碰巧在测试中依赖于任何使用文件位置的东西,比如一些奇怪的程序集加载过程,或者只是像 Assembly.GetExecutingAssembly().Location 这样简单的东西,那么您可能会遇到问题,因为 NUnit 已复制您的文件到构建位置以外的其他位置。
我想说的是,通常这些问题是可以避免的——特别是如果你避免在单元测试中接触文件系统的话。
If you happen to rely on anything that uses a file location in your tests, say for some curious assembly loading process, or just something as simple as Assembly.GetExecutingAssembly().Location, then you're likely to hit problems because NUnit has copied your file to some other location than the build location.
I'd say that typically these problems can be avoided though -- especially if you avoid touching the filesystem in your unit tests.
快速警告,Nunit 的 gradle 插件已更改指定阴影选项的方式。我花了一段时间才找到这个,所以在这里发布,以防它可以帮助其他人。
noShadow被shadowCopy取代,默认为false,即名称变了,其意义/方向相反。这样做显然是为了更接近 Nunit 3 的做法。您可以在插件变更日志中阅读有关此内容的详细信息 https:// github.com/Ullink/gradle-nunit-plugin/blob/master/CHANGELOG.md
A quick warning, the gradle plugin for Nunit has changed how to specify shadow options. Took me a while to find this so posting here in case it can help someone else.
noShadow is replaced by shadowCopy and defaults to false, that is, the name has changed and the sense/direction of it is the opposite. This was done apparently to match more closely what Nunit 3 does. You can read details about this in the plugin changlog at https://github.com/Ullink/gradle-nunit-plugin/blob/master/CHANGELOG.md