1

I have defined a new class name MyTestMethodAttribute and it is been inherited from TestMethod I have changed nothing in this custom attribute other than overriding the Execute Method:

[AttributeUsage(AttributeTargets.Method)]
public class MyTestMethodAttribute : TestMethodAttribute
{
    public override TestResult[] Execute(ITestMethod testMethod)
    {
        // do some stuff here ...

        return base.Execute(testMethod);
    }
 }

So the issue is when I am using [MyTestMethod] attribute over test methods it takes more than 10 minutes to discover test cases of 800 tests but instead when I`m using [TestMethod] attribute it takes less than a few seconds to discover all of the tests and then starting to testing them one by one.

I have also tested it directly using putting the parameters to vstest.console.exe which the TestExproler used to do that as well.

I need to add that even I have not overridden the execute method I am getting the same issue as well.

Ravaei
  • 8
  • 6
  • 1
    Does the same happen when you inherit but do not override `Execute`? – Nkosi Sep 28 '21 at 11:54
  • Yes, the exact thing happens. – Ravaei Sep 28 '21 at 12:12
  • 1
    Probably because it's written that way. This sounds like something to report as a [bug](https://github.com/Microsoft/testfx) (after verifying the latest preview versions don't fix it). A minimal test case would be `[AttributeUsage(AttributeTargets.Method)] public sealed class MyTestMethodAttribute : TestMethodAttribute {}`. Since this does nothing in the most conservative way possible, adding it to methods should not slow down test discovery. If it does, there's some sort of slow path or pathological code in the test discovery that would seem like it needs fixing. – Jeroen Mostert Sep 28 '21 at 12:19

0 Answers0