/// <summary> /// Find and pass all the testcases to discovery sink. /// </summary> /// <param name="sources">Test files containing testcases</param> /// <param name="discoveryContext">discovery context settings</param> /// <param name="logger"></param> /// <param name="discoverySink">Unit test framework Sink</param> public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { BoostTestAdapterSettings settings = BoostTestAdapterSettingsProvider.GetSettings(discoveryContext); var testDiscovererInternal = new BoostTestDiscovererInternal(this.VSProvider, SourceFilterFactory.Get(settings)); IDictionary<string, ProjectInfo> solutioninfo = null; var numberOfAttempts = 100; // try several times to overcome "Application is Busy" COMException while (numberOfAttempts > 0) { try { solutioninfo = testDiscovererInternal.PrepareTestCaseData(sources); // set numberOfAttempts = 0, because there is no need to try again, // since obviously no exception was thrown at this point numberOfAttempts = 0; } catch (COMException) { --numberOfAttempts; // re-throw after all attempts have failed if (numberOfAttempts == 0) { throw; } } } testDiscovererInternal.GetBoostTests(solutioninfo, discoverySink); }
/// <summary> /// Applies the discovery process over the provided DummySolution /// </summary> /// <param name="solution">The dummy solution on which to apply test discovery</param> /// <returns>The list of tests which were discovered from the dummy solution</returns> private IList<TestCase> DiscoverTests(DummySolution solution) { DefaultTestCaseDiscoverySink discoverySink = new DefaultTestCaseDiscoverySink(); ISourceFilter[] filters = new ISourceFilter[] { new QuotedStringsFilter(), new MultilineCommentFilter(), new SingleLineCommentFilter(), new ConditionalInclusionsFilter(new ExpressionEvaluation()) }; BoostTestDiscovererInternal discoverer = new BoostTestDiscovererInternal(solution.Provider, filters); IDictionary<string, ProjectInfo> solutionInfo = discoverer.PrepareTestCaseData(new string[] { solution.Source }); discoverer.GetBoostTests(solutionInfo, discoverySink); return discoverySink.Tests.ToList(); }