in BoostTestAdapter/BoostTestExecutor.cs [176:242]
public void RunTests(IEnumerable<string> sources,
IRunContext runContext,
IFrameworkHandle frameworkHandle)
{
Code.Require(sources, "sources");
Code.Require(runContext, "runContext");
Code.Require(frameworkHandle, "frameworkHandle");
SetUp(frameworkHandle);
Logger.Debug("IRunContext.IsDataCollectionEnabled: {0}", runContext.IsDataCollectionEnabled);
Logger.Debug("IRunContext.RunSettings.SettingsXml: {0}", runContext.RunSettings.SettingsXml);
BoostTestAdapterSettings settings = BoostTestAdapterSettingsProvider.GetSettings(runContext);
foreach (string source in sources)
{
if (_cancelled)
{
break;
}
var discoverer = _boostTestDiscovererFactory.GetDiscoverer(source, settings);
if (discoverer != null)
{
try
{
DefaultTestCaseDiscoverySink sink = new DefaultTestCaseDiscoverySink();
// NOTE IRunContext implements IDiscoveryContext
// NOTE IFrameworkHandle implements IMessageLogger
// Re-discover tests so that we could make use of the RunTests overload which takes an enumeration of test cases.
// This is necessary since we need to run tests one by one in order to have the test adapter remain responsive
// and have a list of tests over which we can generate test results for.
discoverer.DiscoverTests(new[] { source }, runContext, sink);
// The following ensures that only test cases that are not disabled are run when the user presses "Run all"
// This, however, can be overridden by the .runsettings file supplied
IEnumerable<TestCase> testsToRun = GetTestsToRun(settings, sink.Tests);
// Batch tests into grouped runs based by source so that we avoid reloading symbols per test run
// Batching by source since this overload is called when 'Run All...' or equivalent is triggered
// NOTE For code-coverage speed is given preference over adapter responsiveness.
TestBatch.Strategy strategy = ((runContext.IsDataCollectionEnabled) ? TestBatch.Strategy.Source : settings.TestBatchStrategy);
ITestBatchingStrategy batchStrategy = GetBatchStrategy(strategy, settings);
if (batchStrategy == null)
{
Logger.Error(Resources.BatchStrategyNotFoundFor, source);
continue;
}
IEnumerable<TestRun> batches = batchStrategy.BatchTests(testsToRun);
// Delegate to the RunBoostTests overload which takes an enumeration of test batches
RunBoostTests(batches, runContext, frameworkHandle);
}
catch (Exception ex)
{
Logger.Error(Resources.TestException, source, ex.Message);
}
}
}
TearDown();
}