public IEnumerable <TestCase> GetTestCases(ISpecificationDiscoverer discoverer, string sourcePath)
 {
     if (discoverer != null)
     {
         // discover the mspec tests in the assembly and convert them to vstest cases
         foreach (MSpecTestCase mspecTestCase in discoverer.EnumerateSpecs(sourcePath))
         {
             yield return(SpecTestHelper.GetVSTestCaseFromMSpecTestCase(sourcePath, mspecTestCase, MSpecTestAdapter.uri, CreateTrait));
         }
     }
 }
        public void DiscoverTests(IEnumerable <string> sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
        {
            // indicate start of discovery
            logger.SendMessage(TestMessageLevel.Informational, Strings.DISCOVERER_STARTING);
            int discoveredSpecCount = 0;
            int sourcesWithSpecs    = 0;

            Settings settings = GetSettings(discoveryContext);

            foreach (string assemblyPath in sources.Distinct())
            {
                try
                {
#if !NETSTANDARD
                    if (!File.Exists(Path.Combine(Path.GetDirectoryName(Path.GetFullPath(assemblyPath)), "Machine.Specifications.dll")))
                    {
                        continue;
                    }
#endif

                    sourcesWithSpecs++;

                    logger.SendMessage(TestMessageLevel.Informational, string.Format(Strings.DISCOVERER_LOOKINGIN, assemblyPath));

                    List <TestCase> specs = discoverer.DiscoverSpecs(assemblyPath)
                                            .Select(spec => SpecTestHelper.GetVSTestCaseFromMSpecTestCase(assemblyPath, spec, settings.DisableFullTestNameInIDE, MSpecTestAdapter.uri))
                                            .ToList();

                    foreach (TestCase discoveredTest in specs)
                    {
                        discoveredSpecCount++;
                        if (discoverySink != null)
                        {
                            discoverySink.SendTestCase(discoveredTest);
                        }
                    }
                }
                catch (Exception discoverException)
                {
                    logger.SendMessage(TestMessageLevel.Error, string.Format(Strings.DISCOVERER_ERROR, assemblyPath, discoverException.Message));
                }
            }

            // indicate that we are finished discovering
            logger.SendMessage(TestMessageLevel.Informational, string.Format(Strings.DISCOVERER_COMPLETE, discoveredSpecCount, sources.Count(), sourcesWithSpecs));
        }
示例#3
0
        public void DiscoverTests(IEnumerable <string> sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
        {
            // indicate start of discovery
            logger.SendMessage(TestMessageLevel.Informational, "Machine Specifications Visual Studio Test Adapter - Discovering Specifications.");
            int discoveredSpecCount = 0;
            int sourcesWithSpecs    = 0;

            Settings settings = GetSettings(discoveryContext);

            foreach (string assemblyPath in sources.Distinct())
            {
                try
                {
#if !NETSTANDARD
                    if (!File.Exists(Path.Combine(Path.GetDirectoryName(Path.GetFullPath(assemblyPath)), "Machine.Specifications.dll")))
                    {
                        continue;
                    }
#endif

                    sourcesWithSpecs++;

                    logger.SendMessage(TestMessageLevel.Informational, string.Format("Machine Specifications Visual Studio Test Adapter - Discovering...looking in {0}", assemblyPath));

                    List <TestCase> specs = discoverer.DiscoverSpecs(assemblyPath)
                                            .Select(spec => SpecTestHelper.GetVSTestCaseFromMSpecTestCase(assemblyPath, spec, settings.DisableFullTestNameInIDE, MSpecTestAdapter.uri))
                                            .ToList();

                    foreach (TestCase discoveredTest in specs)
                    {
                        discoveredSpecCount++;
                        if (discoverySink != null)
                        {
                            discoverySink.SendTestCase(discoveredTest);
                        }
                    }
                }
                catch (Exception discoverException)
                {
                    logger.SendMessage(TestMessageLevel.Error, string.Format("Machine Specifications Visual Studio Test Adapter - Error while discovering specifications in assembly {0} - {1}", assemblyPath, discoverException.Message));
                }
            }

            // indicate that we are finished discovering
            logger.SendMessage(TestMessageLevel.Informational, string.Format("Machine Specifications Visual Studio Test Adapter - Discovery Complete - {0} specifications in {2} of {1} assemblies scanned.", discoveredSpecCount, sources.Count(), sourcesWithSpecs));
        }