开发者

Noshadow option for nunit-console

开发者 https://www.devze.com 2022-12-15 07:58 出处:网络
I have following ques开发者_开发问答tion : what are advantages and disadvantages in running nunit-console with /noshadow option?

I have following ques开发者_开发问答tion : what are advantages and disadvantages in running nunit-console with /noshadow option? Your comments will be very helpful Thanks


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:

The process cannot access the file 'bin\Debug\calculator.dll' because it is being used by another process.

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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消