Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should we use FxCop on UnitTest assemblies?

We use FxCop for all of our projects. For our UnitTests I am not sure it is worth it. We end up with many suppresses:

[SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = SuppressJustifications.CA1822MethodIsUsedExternallyAsNonStatic)]
[SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "Cantaloupe.Seed.Security.RijndaelEncryption", Justification = SuppressJustifications.CA1806MethodIsCalledForExceptionThrowingTest)]

What are people's thoughts on FxCop on Unit test code?

like image 362
Peter Avatar asked Jan 19 '09 19:01

Peter


2 Answers

When I teach our unit test / TDD class, I usually tell people to write test code following the same principles as they would when writing prober production code. However, I acknowledge that some of the FxCop rules may generate too much noise.

Couldn't you use a suitable subset of the FxCop rules for the test code?

like image 64
Brian Rasmussen Avatar answered Sep 23 '22 05:09

Brian Rasmussen


not worth the effort; FxCop is for production coding standards, not internal test code

(however, it doesn't hurt to give it a run-through and a once-over every now and then, in case it tells you something useful...)

like image 44
Steven A. Lowe Avatar answered Sep 23 '22 05:09

Steven A. Lowe