Example #1
0
 public TestResult(TestRunStatus status, string name, string message, IStackLine[] stackTrace)
 {
     _status = status;
     _name = name;
     _message = message;
     _stackTrace = stackTrace;
 }
Example #2
0
 private TestResult[] queryByStatus(TestRunStatus status)
 {
     var query = from t in _testResults
                 where t.Status.Equals(status)
                 select t;
     return query.ToArray();
 }
Example #3
0
        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();
        }
Example #4
0
 public TestResult(TestRunner runner, TestRunStatus status, string name)
 {
     _runner     = runner;
     _name       = name;
     _status     = status;
     _stackTrace = new IStackLine[] { };
 }
Example #5
0
 public TestResult(TestRunner runner, TestRunStatus status, string name)
 {
     _runner = runner;
     _name = name;
     _status = status;
     _stackTrace = new IStackLine[] { };
 }
Example #6
0
        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);
        }
Example #7
0
 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);
            }
Example #10
0
 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);
 }
Example #11
0
 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);
 }
Example #12
0
 /// <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;
 }
Example #13
0
        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);
        }
Example #15
0
        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);
        }
Example #16
0
        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);
        }
Example #17
0
        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);
        }
Example #18
0
 /// <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;
            }
Example #20
0
		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();
		}
Example #21
0
 public TestResult(TestRunStatus status, string name)
 {
     _name = name;
     _status = status;
 }
Example #22
0
 public TestResult(TestRunStatus status, string name, string message)
 {
     _status = status;
     _name = name;
     _message = message;
 }
Example #23
0
		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;
 }
Example #28
0
        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;
                }
            }
        }
 private void addResult(string line, TestRunStatus status, string lineStart)
 {
     _result.Add(new TestResult(TestRunner.MSTest, status, getChunk(line, lineStart)));
     _lastParsed = lineStart;
 }
        /// <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;
            }
        }