MakePeaceGreatAgain
MakePeaceGreatAgain

Reputation: 37113

VS Test Explorer allways starts discovering tests using standard testadapter

I've written a testadapter by implementing ITestExecutor and ITestDiscoverer:

public class MyDiscoverer : ITestDiscoverer
{
    public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
    {
        foreach (var sourceDllPath in sources.Distinct().Where(x => x.EndsWith(".dll")))
        {
            var ass = Assembly.LoadFrom(source);
            var types = ass.GetTypes();
            foreach(var t in types)
            {
                foreach(var member in t.GetMembers)
                {
                    foreach(var testCase in GetTestCases(member)
                    {
                        var name = $"{ t.Namespace }.{ t.Name }.{ member.Name }";
                        discoverySink.SendTestCase(new TestCase(name, myURL, ass.Location);
                    }
                }
            }
        }
    }
}

I added my adapter as a project-reference to my test-project. However when using the VS-TestExplorer, the "default"-adapter seems to run, because the naming and hierarchical structure of the tests in test-explorer doesn't fit the forementioned code.

enter image description here

As you can see the (parameterized) tests TestCaseWithReturnValue and TestCaseWithoutReturnValue occur twice in TestExplorer. When I finally execute my tests using my ITestExecutor-implementation, only the lower ones are run. So I have a naming-conflict between what my own discoverer returns and what the default-discoverer - whatever that actually is - returns.

So my question is: is there a way to disable the default discocvery-process to avoid naming-conflicts? If not: how would I need to apply the name to my testcases so they apply to the schema of the "default" discoverer? Or in other words: How does the testexplorer examine the correct parts from TestCase("My.Assembly.My.Namespace.MyType.MyMethod")?

Upvotes: 1

Views: 21

Answers (0)

Related Questions