public TestResult(TestRunStatus status, string name, string message, IStackLine[] stackTrace) { _status = status; _name = name; _message = message; _stackTrace = stackTrace; }
private TestResult[] queryByStatus(TestRunStatus status) { var query = from t in _testResults where t.Status.Equals(status) select t; return query.ToArray(); }
public void SetDataFrom(BinaryReader reader) { var stackTrace = new List <IStackLine>(); _runner = (TestRunner)reader.ReadInt32(); _status = (TestRunStatus)reader.ReadInt32(); _name = reader.ReadString(); _displayName = reader.ReadString(); if (_displayName == "") { _displayName = null; } _message = reader.ReadString(); TimeSpent = new TimeSpan((long)reader.ReadDouble()); var count = reader.ReadInt32(); for (int i = 0; i < count; i++) { var method = reader.ReadString(); var file = reader.ReadString(); var lineNumber = reader.ReadInt32(); var line = new StackLineMessage(method, file, lineNumber); stackTrace.Add(line); } _stackTrace = stackTrace.ToArray(); }
public TestResult(TestRunner runner, TestRunStatus status, string name) { _runner = runner; _name = name; _status = status; _stackTrace = new IStackLine[] { }; }
public void TestRunScheduler_VerifyGetTestRunStatus_ReturnsResults() { TimeSpan expectedRunTime = TimeSpan.FromSeconds(40); Mock <ITestRunExecutor> mockExecutor = new Mock <ITestRunExecutor>(); mockExecutor .SetupGet(s => s.ElapsedTime) .Returns(expectedRunTime); mockExecutor .SetupGet(s => s.Status) .Returns(ExecutorStatus.Completed); Mock <ITestRunExecutorFactory> mockFactory = new Mock <ITestRunExecutorFactory>(); mockFactory.Setup(m => m.GetNewTestRunExecutor(It.IsAny <string>())).Returns(mockExecutor.Object); var schedulerUnderTest = new TestRunScheduler(mockFactory.Object); Guid testRunId = schedulerUnderTest.StartNewTestRun("mockTestSuite"); TestRunStatus actual = schedulerUnderTest.GetTestRunStatus(testRunId); Assert.AreEqual(expectedRunTime, actual.CurrentRunTime); Assert.AreEqual(RunStatus.Completed, actual.Status); }
public TestResult(TestRunner runner, TestRunStatus status, string name, string message, IStackLine[] stackTrace) { _runner = runner; _status = status; _name = name; _message = message; _stackTrace = stackTrace; }
private TestResult[] queryByStatus(TestRunStatus status) { var query = from t in _testResults where t.Status.Equals(status) select t; return(query.ToArray()); }
static TestRunStatus?Match(string result, TestRunStatus status, params string[] resultStrings) { if (resultStrings.Any(x => x == result)) { return(status); } return(null); }
public TestResult(TestRunner runner, TestRunStatus status, string name, string message, IStackLine[] stackTrace, double milliseconds) { _runner = runner; _status = status; _name = name; _message = message; _stackTrace = stackTrace; TimeSpent = TimeSpan.FromMilliseconds(milliseconds); }
/// <summary> /// Creates a TestEventArgs instance. /// </summary> /// <param name="status"> A value indicating whether the test succeeded, failed or was skipped. </param> /// <param name="test"> The test that was excecuted. </param> /// <param name="compatibilityMode"> The compatibility mode the test was run under. </param> /// <param name="failureException"> The exception that represents the failure. </param> /// <returns> A TestEventArgs instance. </returns> public TestEventArgs(TestRunStatus status, Test test, bool strictMode, Exception failureException = null) { if (test == null) throw new ArgumentNullException("test"); if (status == TestRunStatus.Failed && failureException == null) throw new ArgumentNullException("failureException"); if (status != TestRunStatus.Failed && failureException != null) throw new ArgumentException("failureException should be null", "failureException"); this.Status = status; this.Test = test; this.StrictMode = strictMode; this.FailureException = failureException; }
private TestItem[] getTests(TestItem[] testItems, TestRunStatus testRunStatus) { var items = new List <TestItem>(); foreach (var item in testItems) { if (item.Value.Status.Equals(testRunStatus)) { items.Add(item); } } return(items.ToArray()); }
private int getImageIndex(TestRunStatus testRunStatus) { switch (testRunStatus) { case TestRunStatus.Passed: return(0); case TestRunStatus.Ignored: return(1); case TestRunStatus.Failed: return(2); } return(2); }
public async Task CompleteTestRunAsync(Guid testRunId, TestRunStatus testRunStatus) { if (testRunStatus == TestRunStatus.InProgress) { throw new ArgumentException("Cannot complete test run with status InProgress!"); } var testRun = await _testRunServiceClient.GetAsync(testRunId).ConfigureAwait(false); testRun.Status = testRunStatus; testRun.DateFinished = _dateTimeProvider.GetCurrentTime(); await _testRunServiceClient.UpdateAsync(testRun.TestRunId, testRun).ConfigureAwait(false); await _testRunOutputServiceClient.DeleteTestRunOutputByTestRunIdAsync(testRun.TestRunId).ConfigureAwait(false); }
public TestRunStatus GetTestRunStatus(Guid testRunId) { if (!_testRunExecutions.ContainsKey(testRunId)) { throw new TestRunNotFoundException($"Test run with id {testRunId} was not found."); } TestRunExecutionDetails runDetails = _testRunExecutions[testRunId]; ITestRunExecutor executor = runDetails.Executor; TestRunStatus status = new TestRunStatus( MapRunStatus(executor.Status), executor.ElapsedTime); return(status); }
public async Task CompleteTestRunAsync(Guid testRunId, TestRunStatus testRunStatus) { if (testRunStatus == TestRunStatus.InProgress) { throw new ArgumentException("Cannot complete test run with status InProgress!"); } var testRun = await _testRunServiceClient.GetAsync(testRunId); testRun.Status = testRunStatus; testRun.DateFinished = _dateTimeProvider.GetCurrentTime(); // DEBUG: Before COMPLETING RUN ////Console.WriteLine("Before COMPLETING RUN"); await _testRunServiceClient.UpdateAsync(testRun.TestRunId, testRun); await _testRunOutputServiceClient.DeleteTestRunOutputByTestRunIdAsync(testRun.TestRunId); }
/// <summary> /// Creates a TestEventArgs instance. /// </summary> /// <param name="status"> A value indicating whether the test succeeded, failed or was skipped. </param> /// <param name="test"> The test that was excecuted. </param> /// <param name="compatibilityMode"> The compatibility mode the test was run under. </param> /// <param name="failureException"> The exception that represents the failure. </param> /// <returns> A TestEventArgs instance. </returns> public TestEventArgs(TestRunStatus status, Test test, bool strictMode, Exception failureException = null) { if (test == null) { throw new ArgumentNullException("test"); } if (status == TestRunStatus.Failed && failureException == null) { throw new ArgumentNullException("failureException"); } if (status != TestRunStatus.Failed && failureException != null) { throw new ArgumentException("failureException should be null", "failureException"); } this.Status = status; this.Test = test; this.StrictMode = strictMode; this.FailureException = failureException; }
static TestRunStatus? Match(string result, TestRunStatus status, params string[] resultStrings) { if (resultStrings.Any(x => x == result)) { return status; } return null; }
public void SetDataFrom(BinaryReader reader) { var stackTrace = new List<IStackLine>(); _runner = (TestRunner)reader.ReadInt32(); _status = (TestRunStatus) reader.ReadInt32(); _name = reader.ReadString(); _displayName = reader.ReadString(); if (_displayName == "") _displayName = null; _message = reader.ReadString(); TimeSpent = new TimeSpan((long)reader.ReadDouble()); var count = reader.ReadInt32(); for (int i = 0; i < count; i++) { var method = reader.ReadString(); var file = reader.ReadString(); var lineNumber = reader.ReadInt32(); var line = new StackLineMessage(method, file, lineNumber); stackTrace.Add(line); } _stackTrace = stackTrace.ToArray(); }
public TestResult(TestRunStatus status, string name) { _name = name; _status = status; }
public TestResult(TestRunStatus status, string name, string message) { _status = status; _name = name; _message = message; }
public void SetDataFrom(BinaryReader reader) { var stackTrace = new List<IStackLine>(); _runner = (TestRunner)reader.ReadInt32(); _status = (TestRunStatus) reader.ReadInt32(); _name = reader.ReadString(); _message = reader.ReadString(); var count = reader.ReadInt32(); for (int i = 0; i < count; i++) { var method = reader.ReadString(); var file = reader.ReadString(); var lineNumber = reader.ReadInt32(); var line = new StackLineMessage(method, file, lineNumber); stackTrace.Add(line); } _stackTrace = stackTrace.ToArray(); }
public async Task ThrowInvalidOperationException_When_MoreThanOneTestRunExistForProvidedTestRunId_AndStatus(TestRunStatus status) { // Arrange var testRuns = TestRunFactory.CreateMany(_testRunId); _testRunRepositoryMock.Setup(x => x.GetAllAsync()).Returns(Task.FromResult(testRuns)); // Act var action = new TestDelegate(() => _testRunProvider.CompleteTestRunAsync(_testRunId, status)); // Assert Assert.That(action, Throws.Exception.TypeOf <InvalidOperationException>()); }
public async Task ShouldUpdateTestRunStatusToProvidedValue_When_OneTestRunExistForProvidedTestRunId_AndOtherTestRunsExists_AndStatus(TestRunStatus status) { // Arrange var currentTestRun = TestRunFactory.CreateSingleInProgress(_testRunId); var otherTestRuns = TestRunFactory.CreateMany(); _testRunRepositoryMock.Setup(x => x.GetAllAsync()).Returns(Task.FromResult(currentTestRun.Union(otherTestRuns))); // Act _testRunProvider.CompleteTestRunAsync(_testRunId, status); // Assert _testRunRepositoryMock.Verify(x => x.UpdateAsync(It.IsAny <int>(), It.Is <TestRunDto>(i => i.TestRunId == _testRunId && i.Status == status)), Times.Once); _testRunRepositoryMock.Verify(x => x.UpdateAsync(It.IsAny <int>(), It.IsAny <TestRunDto>()), Times.Once); }
private void addResult(string line, TestRunStatus status, string lineStart) { _result.Add(new TestResult(TestRunner.MSTest, status, getChunk(line, lineStart))); _lastParsed = lineStart; }
private int getImageIndex(TestRunStatus testRunStatus) { switch (testRunStatus) { case TestRunStatus.Passed: return 0; case TestRunStatus.Ignored: return 1; case TestRunStatus.Failed: return 2; } return 2; }
public static void Main(string[] args) { PrintUsage(); TestRunScheduler scheduler = new TestRunScheduler(); bool exit = false; while (!exit) { string userInput = Console.ReadLine(); string invokedVerb = null; object invokedVerbInstance = null; var options = new Options(); if (!CommandLine.Parser.Default.ParseArguments(userInput.Split(' '), options, (verb, subOptions) => { invokedVerb = verb; invokedVerbInstance = subOptions; })) { Console.WriteLine($"Unrecognized command: {userInput}."); PrintUsage(); continue; } switch (invokedVerb) { case "exit": exit = true; Console.WriteLine("Exiting test runner."); scheduler.CancelAllTestRuns(); continue; case "start": var startRunOptions = (StartNewTestRunOptions)invokedVerbInstance; Console.WriteLine($"Starting test run of {startRunOptions.TestSuiteName}."); Guid testRunId = scheduler.StartNewTestRun(startRunOptions.TestSuiteName); Console.WriteLine($"Started test run with id {testRunId}."); break; case "status": var statusOptions = (CommonOptions)invokedVerbInstance; try { Console.WriteLine($"Retrieving status of test run with id {statusOptions.TestRunGuid}."); TestRunStatus status = scheduler.GetTestRunStatus(Guid.Parse(statusOptions.TestRunGuid)); Console.WriteLine(status); } catch (TestRunNotFoundException ex) { Console.WriteLine("Failed to retrieve status of test run:"); Console.WriteLine(ex.Message); } break; case "results": var resultsOptions = (CommonOptions)invokedVerbInstance; try { Console.WriteLine($"Retrieving results of test run with id {resultsOptions.TestRunGuid}."); TestRunResults results = scheduler.GetTestRunResults(Guid.Parse(resultsOptions.TestRunGuid)); Console.WriteLine(results); } catch (TestRunNotFoundException ex) { Console.WriteLine("Failed to retrieve results of test run:"); Console.WriteLine(ex.Message); } break; case "cancel": var cancelRunOptions = (CommonOptions)invokedVerbInstance; try { Console.WriteLine($"Canceling test run with id {cancelRunOptions.TestRunGuid}."); scheduler.CancelTestRun(Guid.Parse(cancelRunOptions.TestRunGuid)); Console.WriteLine("Test run canceled."); } catch (TestRunNotFoundException ex) { Console.WriteLine("Failed to cancel test run:"); Console.WriteLine(ex.Message); } break; } } }
/// <summary> /// Updates the status of the specified test run. /// </summary> /// <param name="id">The identifier of the test run within the database.</param> /// <param name="status">The status to set for the specified test run.</param> /// <returns>A <see cref="TestRunStatus"/> value specifying the test run's previous status.</returns> public TestRunStatus UpdateTestRunStatus(Int64 id, TestRunStatus status) { using (var testRunContext = new TestRunContext()) { var run = testRunContext.TestRuns.Where(x => x.ID == id).Single(); var previousStatus = run.Status; run.Status = status; testRunContext.SaveChanges(); return previousStatus; } }