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 MSpecTestAdapter(ISpecificationDiscoverer discoverer, ISpecificationExecutor executor) { if (executor == null) throw new ArgumentNullException(nameof(executor)); if (discoverer == null) throw new ArgumentNullException(nameof(discoverer)); this.executor = executor; this.discoverer = discoverer; // check if a version of visual studio that supports traits is running vsObjectModel = AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName.StartsWith(VSObjectModelAssemblyName)).SingleOrDefault(); if (vsObjectModel != null) { FileVersionInfo fileInfo = FileVersionInfo.GetVersionInfo(vsObjectModel.Location); if ((fileInfo.FileMajorPart == 11 && fileInfo.ProductBuildPart > 50727) || fileInfo.FileMajorPart >= 12) { UseTraits = true; } } }
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; foreach (string assemblyPath in sources) { try { ISpecificationDiscoverer specificationDiscoverer = this.adapterFactory.CreateDiscover(); // only bother discovering if mspec is available and the assembly to san has a reference to mspec if (specificationDiscoverer.SourceDirectoryContainsMSpec(assemblyPath) && specificationDiscoverer.AssemblyContainsMSpecReference(assemblyPath)) { sourcesWithSpecs++; // indicate which assembly we are looking in logger.SendMessage(TestMessageLevel.Informational, string.Format(Strings.DISCOVERER_LOOKINGIN, assemblyPath)); // do the actual discovery foreach (TestCase discoveredTest in this.GetTestCases((ISpecificationDiscoverer)specificationDiscoverer, assemblyPath)) { 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)); }
public MSpecTestAdapter(ISpecificationDiscoverer discoverer, ISpecificationExecutor executor) { if (executor == null) { throw new ArgumentNullException(nameof(executor)); } if (discoverer == null) { throw new ArgumentNullException(nameof(discoverer)); } this.executor = executor; this.discoverer = discoverer; // check if a version of visual studio that supports traits is running vsObjectModel = AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName.StartsWith(VSObjectModelAssemblyName)).SingleOrDefault(); if (vsObjectModel != null) { FileVersionInfo fileInfo = FileVersionInfo.GetVersionInfo(vsObjectModel.Location); if ((fileInfo.FileMajorPart == 11 && fileInfo.ProductBuildPart > 50727) || fileInfo.FileMajorPart >= 12) { UseTraits = true; } } }
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 MSpecTestAdapter(ISpecificationDiscoverer discoverer, ISpecificationExecutor executor) { this.executor = executor ?? throw new ArgumentNullException(nameof(executor)); this.discoverer = discoverer ?? throw new ArgumentNullException(nameof(discoverer)); }