Пример #1
0
 public DiscoveredTestCase(string source, ITestFrameworkDiscoverer discoverer, ITestCase testCase, LoggerHelper logger, bool designMode)
 {
     Name       = $"{testCase.TestMethod.TestClass.Class.Name}.{testCase.TestMethod.Method.Name}";
     TraitNames = testCase.Traits.Keys;
     VSTestCase = VsDiscoverySink.CreateVsTestCase(source, discoverer, testCase, forceUniqueName: false, logger: logger, designMode: designMode);
     uniqueID   = testCase.UniqueID;
 }
Пример #2
0
            public DiscoveredTestCase(string source, ITestFrameworkDiscoverer discoverer, ITestCase testCase, LoggerHelper logger, TestPlatformContext testPlatformContext)
            {
                var testMethod     = testCase.TestMethod;
                var testClassName  = testMethod.TestClass.Class.Name;
                var testMethodName = testMethod.Method.Name;

                Name       = $"{testClassName}.{testMethodName}";
                TestCase   = testCase;
                UniqueID   = testCase.UniqueID;
                VSTestCase = VsDiscoverySink.CreateVsTestCase(source, discoverer, testCase, false, logger, testPlatformContext, testClassName, testMethodName, UniqueID);
                TraitNames = testCase.Traits.Keys;
            }
Пример #3
0
        List <AssemblyRunInfo> GetTests(IEnumerable <string> sources, LoggerHelper logger, IRunContext runContext)
        {
            // For store apps, the files are copied to the AppX dir, we need to load it from there
#if PLATFORM_DOTNET
            sources = sources.Select(s => Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, Path.GetFileName(s)));
#endif

            var result          = new List <AssemblyRunInfo>();
            var knownTraitNames = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            DiscoverTests(
                sources,
                logger,
                (source, discoverer, discoveryOptions) => new VsExecutionDiscoverySink(() => cancelled),
                (source, discoverer, discoveryOptions, visitor) =>
            {
                var vsFilteredTestCases = visitor.TestCases.Select(testCase => VsDiscoverySink.CreateVsTestCase(source, discoverer, testCase, false, logger: logger, knownTraitNames: knownTraitNames)).ToList();

                // Apply any filtering
                var filterHelper    = new TestCaseFilterHelper(knownTraitNames);
                vsFilteredTestCases = filterHelper.GetFilteredTestList(vsFilteredTestCases, runContext, logger, source).ToList();

                // Re-create testcases with unique names if there is more than 1
                var testCases = visitor.TestCases.Where(tc => vsFilteredTestCases.Any(vsTc => vsTc.DisplayName == tc.DisplayName))
                                .GroupBy(tc => $"{tc.TestMethod.TestClass.Class.Name}.{tc.TestMethod.Method.Name}")
                                .SelectMany(group => group.Select(testCase => VsDiscoverySink.CreateVsTestCase(source, discoverer, testCase, forceUniqueNames: group.Count() > 1, logger: logger, knownTraitNames: knownTraitNames))
                                            .Where(vsTestCase => vsTestCase != null)).ToList();          // pre-enumerate these as it populates the known trait names collection

                var runInfo = new AssemblyRunInfo
                {
                    AssemblyFileName = source,
                    Configuration    = LoadConfiguration(source),
                    TestCases        = testCases
                };
                result.Add(runInfo);
            }
                );

            return(result);
        }
Пример #4
0
 public void ForceUniqueName()
 {
     VsDiscoverySink.ForceUniqueName(VSTestCase, uniqueID);
 }