internal TestCaseViewModel(string assemblyFileName, ITestCase testCase, INavigation navigation, ITestRunner runner) { if (assemblyFileName == null) { throw new ArgumentNullException(nameof(assemblyFileName)); } if (testCase == null) { throw new ArgumentNullException(nameof(testCase)); } this.navigation = navigation; this.runner = runner; AssemblyFileName = assemblyFileName; TestCase = testCase; Result = TestState.NotRun; RunStatus = RunStatus.NotRun; Message = "not run"; // Create an initial result representing not run TestResult = new TestResultViewModel(this, null); NavigateToResultCommand = new DelegateCommand(NavigateToResultsPage); }
public void RecordResult(TestResultViewModel result) { lock (lockOjb) { if (writer == null) { return; } if (result.TestCase.Result == TestState.Passed) { writer.Write("\t[PASS] "); passed++; } else if (result.TestCase.Result == TestState.Skipped) { writer.Write("\t[SKIPPED] "); skipped++; } else if (result.TestCase.Result == TestState.Failed) { writer.Write("\t[FAIL] "); failed++; } else { writer.Write("\t[INFO] "); } writer.Write(result.TestCase.DisplayName); var message = result.ErrorMessage; if (!string.IsNullOrEmpty(message)) { writer.Write(" : {0}", message.Replace("\r\n", "\\r\\n")); } writer.WriteLine(); var stacktrace = result.ErrorStackTrace; if (!string.IsNullOrEmpty(result.ErrorStackTrace)) { var lines = stacktrace.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { writer.WriteLine("\t\t{0}", line); } } } }
public void RecordResult(TestResultViewModel result) { lock (lockOjb) { if (writer == null) return; if (result.TestCase.Result == TestState.Passed) { writer.Write("\t[PASS] "); passed++; } else if (result.TestCase.Result == TestState.Skipped) { writer.Write("\t[SKIPPED] "); skipped++; } else if (result.TestCase.Result == TestState.Failed) { writer.Write("\t[FAIL] "); failed++; } else { writer.Write("\t[INFO] "); } writer.Write(result.TestCase.DisplayName); var message = result.ErrorMessage; if (!string.IsNullOrEmpty(message)) { writer.Write(" : {0}", message.Replace("\r\n", "\\r\\n")); } writer.WriteLine(); var stacktrace = result.ErrorStackTrace; if (!string.IsNullOrEmpty(result.ErrorStackTrace)) { var lines = stacktrace.Split(new[] {'\r', '\n'}, StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) writer.WriteLine("\t\t{0}", line); } } }
internal TestCaseViewModel(string assemblyFileName, ITestCase testCase, bool forceUniqueNames, INavigation navigation, ITestRunner runner) { if (assemblyFileName == null) throw new ArgumentNullException("assemblyFileName"); if (testCase == null) throw new ArgumentNullException("testCase"); this.navigation = navigation; this.runner = runner; fqTestMethodName = String.Format("{0}.{1}", testCase.TestMethod.TestClass.Class.Name, testCase.TestMethod.Method.Name); UniqueName = forceUniqueNames ? String.Format("{0} ({1})", fqTestMethodName, testCase.UniqueID) : fqTestMethodName; AssemblyFileName = assemblyFileName; TestCase = testCase; Result = TestState.NotRun; Message = "not run"; // Create an initial result representing not run TestResult = new TestResultViewModel(this, null); NavigateToResultCommand = new Command(NavigateToResultsPage); }
internal TestCaseViewModel(string assemblyFileName, ITestCase testCase, INavigation navigation, ITestRunner runner) { if (assemblyFileName == null) throw new ArgumentNullException(nameof(assemblyFileName)); if (testCase == null) throw new ArgumentNullException(nameof(testCase)); this.navigation = navigation; this.runner = runner; AssemblyFileName = assemblyFileName; TestCase = testCase; Result = TestState.NotRun; RunStatus = RunStatus.NotRun; Message = "not run"; // Create an initial result representing not run TestResult = new TestResultViewModel(this, null); NavigateToResultCommand = new DelegateCommand(NavigateToResultsPage); }
internal void UpdateTestState(TestResultViewModel message) { TestResult = message; Output = message.TestResultMessage.Output ?? string.Empty; var msg = string.Empty; var stackTrace = string.Empty; var rs = Runners.RunStatus.NotRun; if (message.TestResultMessage is ITestPassed) { Result = TestState.Passed; msg = $"Success! {TestResult.Duration.TotalMilliseconds} ms"; rs = RunStatus.Ok; } if (message.TestResultMessage is ITestFailed) { Result = TestState.Failed; var failedMessage = (ITestFailed)(message.TestResultMessage); msg = ExceptionUtility.CombineMessages(failedMessage); stackTrace = ExceptionUtility.CombineStackTraces(failedMessage); rs = RunStatus.Failed; } if (message.TestResultMessage is ITestSkipped) { Result = TestState.Skipped; var skipped = (ITestSkipped)(message.TestResultMessage); msg = skipped.Reason; rs = RunStatus.Skipped; } Message = msg; StackTrace = stackTrace; RunStatus = rs; }
public void RecordResult(TestResultViewModel result) { resultChannel.RecordResult(result); }
internal void UpdateTestState(TestResultViewModel message) { TestResult = message; Output = message.TestResultMessage.Output; Message = null; StackTrace = null; if (message.TestResultMessage is ITestPassed) { Result = TestState.Passed; Message = String.Format("Success! {0} ms", TestResult.Duration.TotalMilliseconds); DetailColor = Color.Green; } if (message.TestResultMessage is ITestFailed) { Result = TestState.Failed; var failedMessage = (ITestFailed)(message.TestResultMessage); Message = ExceptionUtility.CombineMessages(failedMessage); StackTrace = ExceptionUtility.CombineStackTraces(failedMessage); DetailColor = Color.Red; } if (message.TestResultMessage is ITestSkipped) { Result = TestState.Skipped; var skipped = (ITestSkipped)(message.TestResultMessage); Message = skipped.Reason; DetailColor = Color.FromHex("#FF7700"); } }
//private void OnTestRunCompleted() //{ // window.BeginInvokeOnMainThread( // () => // { // foreach (var ts in suite_elements.Values) // { // // Recalc the status // ts.Update(); // } // }); //} void ITestListener.RecordResult(TestResultViewModel result) { // TODO: Find out why this is happening on WP8 var writer = Writer; if (writer == null) return; if (result.TestCase.Result == TestState.Passed) { writer.Write("\t[PASS] "); passed++; } else if (result.TestCase.Result == TestState.Skipped) { writer.Write("\t[SKIPPED] "); skipped++; } else if (result.TestCase.Result == TestState.Failed) { writer.Write("\t[FAIL] "); failed++; } else { writer.Write("\t[INFO] "); } writer.Write(result.TestCase.DisplayName); var message = result.ErrorMessage; if (!String.IsNullOrEmpty(message)) { writer.Write(" : {0}", message.Replace("\r\n", "\\r\\n")); } writer.WriteLine(); var stacktrace = result.ErrorStackTrace; if (!String.IsNullOrEmpty(result.ErrorStackTrace)) { var lines = stacktrace.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) writer.WriteLine("\t\t{0}", line); } }