Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bbusacker opened this issue Mar 14, 2016 · 1 comment
Labels

Comments

@bbusacker
Copy link

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);
            }
        }
@csoltenborn
Copy link
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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants