public void RunTests(IEnumerable <TestCase> allTestCases, IEnumerable <TestCase> testCasesToRun, string baseDir, string workingDir, string userParameters, bool isBeingDebugged, IDebuggedProcessLauncher debuggedLauncher, IProcessExecutor executor) { DebugUtils.AssertIsNull(userParameters, nameof(userParameters)); DebugUtils.AssertIsNull(workingDir, nameof(workingDir)); try { Stopwatch stopwatch = Stopwatch.StartNew(); string testDirectory = Utils.GetTempDirectory(); workingDir = _settings.GetWorkingDir(_solutionDirectory, testDirectory, _threadId); userParameters = _settings.GetUserParameters(_solutionDirectory, testDirectory, _threadId); string batch = _settings.GetBatchForTestSetup(_solutionDirectory, testDirectory, _threadId); batch = batch == "" ? "" : _solutionDirectory + batch; SafeRunBatch(TestSetup, _solutionDirectory, batch, isBeingDebugged); _innerTestRunner.RunTests(allTestCases, testCasesToRun, baseDir, workingDir, userParameters, isBeingDebugged, debuggedLauncher, executor); batch = _settings.GetBatchForTestTeardown(_solutionDirectory, testDirectory, _threadId); batch = batch == "" ? "" : _solutionDirectory + batch; SafeRunBatch(TestTeardown, _solutionDirectory, batch, isBeingDebugged); stopwatch.Stop(); _logger.DebugInfo($"{_threadName}Execution took {stopwatch.Elapsed}"); string errorMessage; if (!Utils.DeleteDirectory(testDirectory, out errorMessage)) { _logger.DebugWarning( $"{_threadName}Could not delete test directory '" + testDirectory + "': " + errorMessage); } } catch (Exception e) { _logger.LogError($"{_threadName}Exception while running tests: " + e); } }
public void RunTests(IEnumerable <TestCase> testCasesToRun, string baseDir, string workingDir, string userParameters, bool isBeingDebugged, IDebuggedProcessLauncher debuggedLauncher, IProcessExecutor executor) { DebugUtils.AssertIsNull(userParameters, nameof(userParameters)); DebugUtils.AssertIsNull(workingDir, nameof(workingDir)); try { Stopwatch stopwatch = Stopwatch.StartNew(); string testDirectory = Utils.GetTempDirectory(); workingDir = _settings.GetWorkingDir(_solutionDirectory, testDirectory, _threadId); userParameters = _settings.GetUserParameters(_solutionDirectory, testDirectory, _threadId); string batch = _settings.GetBatchForTestSetup(_solutionDirectory, testDirectory, _threadId); batch = batch == "" ? "" : _solutionDirectory + batch; SafeRunBatch(BatchType.TestSetup, _solutionDirectory, batch, isBeingDebugged); _innerTestRunner.RunTests(testCasesToRun, baseDir, workingDir, userParameters, isBeingDebugged, debuggedLauncher, executor); batch = _settings.GetBatchForTestTeardown(_solutionDirectory, testDirectory, _threadId); batch = batch == "" ? "" : _solutionDirectory + batch; SafeRunBatch(BatchType.TestTeardown, _solutionDirectory, batch, isBeingDebugged); stopwatch.Stop(); _logger.DebugInfo(String.Format(Resources.ExecutionTime, _threadName, stopwatch.Elapsed)); string errorMessage; if (!Utils.DeleteDirectory(testDirectory, out errorMessage)) { _logger.DebugWarning(String.Format(Resources.DeleteTestDir, _threadName, testDirectory, errorMessage)); } } catch (Exception e) { _logger.LogError(String.Format(Resources.ExceptionMessage, _threadName, e)); } }