Unit Testing Custom Code Analysis Rules in 2010 - Any Hope
In the past it has been a real PITA to unit test custom Code Analysis rules. I haven't found anything out there that shows the situation to be any different i开发者_StackOverflow中文版n 2010, but I'm not giving up. If anyone knows if this is "possible" in 2010 please respond - thanks!
Johnathan,
I should've posted this sooner...I eventually figured this out in VS2010, and it's actually quite easy:
http://www.jasonbock.net/JB/Default.aspx?blog=entry.d6f6046800d945e6b94e8d92a4da52c2
Sounds like you have to do it the old fashioned way.
- Create a test project that demonstrates all the issues you are supposed to catch.
- Create a test harness that executes MSBuild against your test project and captures the output.
- Parse the results looking for the errors you intended.
精彩评论