/// <summary> /// ITestDiscover, Given a list of test sources this method pulls out the test cases /// </summary> /// <param name="sources">List of test sources passed from client (Client can be VS or command line)</param> /// <param name="discoveryContext">Context and runSettings for current run. Discoverer pulls out the tests based on current context</param> /// <param name="logger">Used to relay messages to registered loggers</param> /// <param name="discoverySink">Callback used to notify client upon discovery of test cases</param> public void DiscoverTests(IEnumerable <string> sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { ValidateArg.NotNull(sources, "sources"); ValidateArg.NotNull(discoverySink, "discoverySink"); ValidateArg.NotNull(logger, "logger"); using (var buildEngine = new MSBuild.ProjectCollection()) { try { // Load all the test containers passed in (.njsproj msbuild files) foreach (string source in sources) { buildEngine.LoadProject(source); } foreach (var proj in buildEngine.LoadedProjects) { var projectHome = Path.GetFullPath(Path.Combine(proj.DirectoryPath, ".")); Dictionary <string, List <TestFileEntry> > testItems = new Dictionary <string, List <TestFileEntry> >(StringComparer.OrdinalIgnoreCase); // Provide all files to the test analyzer foreach (var item in proj.Items.Where(item => item.ItemType == "Compile" || item.ItemType == "TypeScriptCompile")) { //Check to see if this is a TestCase string value = item.GetMetadataValue("TestFramework"); if (!TestContainerDiscoverer.IsValidTestFramework(value)) { continue; } string fileAbsolutePath = CommonUtils.GetAbsoluteFilePath(projectHome, item.EvaluatedInclude); bool typeScriptTest = TypeScript.TypeScriptHelpers.IsTypeScriptFile(fileAbsolutePath); if (typeScriptTest) { fileAbsolutePath = TypeScript.TypeScriptHelpers.GetTypeScriptBackedJavaScriptFile(proj, fileAbsolutePath); } else if (!Path.GetExtension(fileAbsolutePath).Equals(".js", StringComparison.OrdinalIgnoreCase)) { continue; } List <TestFileEntry> fileList; if (!testItems.TryGetValue(value, out fileList)) { fileList = new List <TestFileEntry>(); testItems.Add(value, fileList); } fileList.Add(new TestFileEntry(fileAbsolutePath, typeScriptTest)); } //Debug.Fail("Before Discover"); DiscoverTests(testItems, proj, discoverySink, logger); } } catch (Exception ex) { logger.SendMessage(TestMessageLevel.Error, ex.Message); throw; } finally { // Disposing buildEngine does not clear the document cache in // VS 2013, so manually unload all projects before disposing. buildEngine.UnloadAllProjects(); } } }
public TestMethodResolver([Import(typeof(SVsServiceProvider))]IServiceProvider serviceProvider, [Import]TestContainerDiscoverer discoverer) { _serviceProvider = serviceProvider; _discoverer = discoverer; }
public ProjectInfo(IVsProject project, TestContainerDiscoverer discoverer) { this.Project = project; this.Discoverer = discoverer; }
public TestMethodResolver([Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider, [Import] TestContainerDiscoverer discoverer) { this.serviceProvider = serviceProvider; this.discoverer = discoverer; }
public ProjectInfo(IVsProject project, TestContainerDiscoverer discoverer) { Project = project; Discoverer = discoverer; }