Skip to content

Specifying a TestCaseFilter still runs all tests but displays only results for filtered tests #36

Closed
@bbusacker

Description

@bbusacker

This makes it appear as though filters are working even though they really aren't.

Here is the fix:

There is a check (AllTestCasesOfExecutableAreRun()) in CommandLineGenerator.cs if the testCases match all test cases. If they do you don't add any filters. I found this because my tests were taking a long time even when I was executing a few. It turned out all test cases were being run even though a filter was passed in as an argument to vstest.console.exe.

In TestExecutor.cs

public void RunTests(IEnumerable<string> executables, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            try
            {
                InitTestEnvironment(runContext.RunSettings, frameworkHandle);

                IList<Model.TestCase> allTestCasesInExecutables = GetAllTestCasesInExecutables(executables).ToList();

                ISet<string> allTraitNames = GetAllTraitNames(allTestCasesInExecutables);
                TestCaseFilter filter = new TestCaseFilter(runContext, allTraitNames, TestEnvironment);
                List<TestCase> vsTestCases =
                    filter.Filter(allTestCasesInExecutables.Select(DataConversionExtensions.ToVsTestCase)).ToList();

>>>>>>>>>>>>               allTestCasesInExecutables =
>>>>>>>>>>>>>>>>>>                    allTestCasesInExecutables.Where(tc => vsTestCases.Any(vtc => >>>>>>>>>>>>>>>>>>  tc.FullyQualifiedName == vtc.FullyQualifiedName)).ToList();

>>>>>>>>>>>>>>>>>>> DoRunTests(allTestCasesInExecutables, allTestCasesInExecutables, runContext, frameworkHandle);

Change to:
>>>>>>>>>>>>                var testCasesToRun =
>>>>>>>>>>>>>>>>>>                    allTestCasesInExecutables.Where(tc => vsTestCases.Any(vtc => >>>>>>>>>>>>>>>>>>  tc.FullyQualifiedName == vtc.FullyQualifiedName)).ToList();

>>>>>>>>>>>>>>>>>>> DoRunTests(allTestCasesInExecutables, testCasesToRun, runContext, frameworkHandle);
            }
            catch (Exception e)
            {
                TestEnvironment.LogError("Exception while running tests: " + e);
            }
        }

Activity

csoltenborn

csoltenborn commented on Mar 15, 2016

@csoltenborn
Owner

Thanks for bug report and fix - that's a weird one... bugfix release will follow soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @csoltenborn@bbusacker

        Issue actions

          Specifying a TestCaseFilter still runs all tests but displays only results for filtered tests · Issue #36 · csoltenborn/GoogleTestAdapter