Consider the following repro example (MS Test unit test code):
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace UnitTestProject1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
SharedMethod();
}
[TestMethod, ExcludeFromCodeCoverage]
public void TestMethod2()
{
SharedMethod();
// This is a performance test which will fail during coverage analysis.
Assert.Fail();
}
private void SharedMethod()
{
// Should be green
if (true) ; // NOOP
}
}
}
TestMethod2 is a performance test method, which will succeed during "regular" unit test but fail during code coverage analysis (due to the additional overhead). That's fine. I just want that method to be ignored during code coverage analysis, so that my SharedMethod is shown as "green" (because it's successfully covered by TestMethod1.
According to JetBrains, coverage filters should do that, and, yes, there is a filter active for ExcludeFromCodeCoverageAttribute:
However, running Extensions/ReSharper/Unit Tests/"Cover All Tests From Solution" still considers my excluded test when coloring my code:
What did I do wrong? And how do I (easily) exclude my performance tests from Code Coverage analysis?



TestMethod2is already not shown in the coverage window (probably because a runtime filter exists), so I can't add a coverage filter for it. - Heinzi