Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mark a method as not needing to be tested? (ASP.NET, ReSharper) [duplicate]

I have an ASP.NET project and I'm using ReSharper to do my unit testing along with dotCover. I'm looking for a way to mark a method as not needing to be tested. I For example, I have some simple one-liner methods that send work elsewhere and return the result. The methods that do the actual work are covered by unit tests, but these "intermediate" methods don't need to be.

These methods will show as uncovered by ReSharper. I'd like to be able to flag them so they don't show as covered or uncovered. This would let me explicitly state when I have code that, for whatever reason, will be excluded from my unit tests and does not need to be concerned about being covered.

like image 546
Phil Ringsmuth Avatar asked Oct 27 '25 09:10

Phil Ringsmuth


1 Answers

Thanks to Alexei Levenkov, a similar question with a great answer has already been asked. In short, ASP.NET now has an [ExcludeFromCodeCoverage] attribute that can be added to a class or a method. Once ReSharper re-analyzed my code coverage, it no longer shows these methods as uncovered.

https://stackoverflow.com/a/1603193/529554

like image 194
Phil Ringsmuth Avatar answered Oct 29 '25 22:10

Phil Ringsmuth