开发者

Run all stylecop rules in unit test

Is there anyway to run all 开发者_开发技巧StyleCop rules from a unit test (equivalent to rescan all) and assert based on warnings?

Thanks in advance!

/Jasper


Technically, you can do it, but it is very (!) unusual way of using StyleCop.

First, you should learn how to run StyleCop from the code. This discussion contains some examples that can help implementing this: http://stylecop.codeplex.com/discussions/220546.

Then, you will be able to create unit-test that will enumerate and check all source files in specified location. The bad part here is that you will need to specify this location somehow, and unit-test will work with source codes instead of compiled assembly (which is rather untypical).

But anyway, I would recommend reconsidering your approach. It is not really required to consider StyleCop error as compilation errors. You could perform analysis on build-server and share the results in any way you like (the same thing about unit-tests) - everything in your hands!


I'd just include it in my build-process and treat a build as failed if there're warnings (via a nant or ant return code or something similar). You can configure these tools to only spit out the warnings you want.

Why do you need it in a Unit-Test anyway?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜