public void TestFinished(AutoTest.TestRunners.Shared.Results.TestResult result) { lock (_padLock) { _currentAssembly = result.Assembly; _testCount++; if (result.State == TestState.Passed && _runCache.Failed.Count(x => x.Value.Name.Equals(result.TestName)) != 0) { _bus.Publish( new LiveTestStatusMessage( _currentAssembly, _currentTest, _totalTestCount, _testCount, new LiveTestStatus[] { }, new LiveTestStatus[] { new LiveTestStatus(result.Assembly, AutoTestTestRunner.ConvertResult(result)) })); _lastSend = DateTime.Now; return; } if (result.State == TestState.Failed) { _bus.Publish( new LiveTestStatusMessage( _currentAssembly, _currentTest, _totalTestCount, _testCount, new LiveTestStatus[] { new LiveTestStatus(result.Assembly, AutoTestTestRunner.ConvertResult(result)) }, new LiveTestStatus[] { })); _lastSend = DateTime.Now; } } }
public static Messages.TestResult ConvertResult(AutoTest.TestRunners.Shared.Results.TestResult x) { return(new Messages.TestResult(TestRunnerConverter.FromString(x.Runner), getTestState(x.State), x.TestName, x.Message, x.StackLines.Select(y => (IStackLine) new StackLineMessage(y.Method, y.File, y.Line)).ToArray <IStackLine>(), x.DurationInMilliseconds )); }
public void TestFinished(TestResult result) { if (result == null) { Logger.Write(" - Testresult was null"); return; } var xml = result.ToXml(); if (xml == null) { Logger.Write(" - Could not generate xml from " + result.TestName); return; } Logger.Write(" - {0}", result.State.ToString()); _channel.Send(xml); }
public void Should_publish_status_every_second() { _cache.Stub(x => x.Failed).Return(new TestItem[] { }); var test = new AutoTest.TestRunners.Shared.Results.TestResult("", "", "", 0, "Passing test", AutoTest.TestRunners.Shared.Results.TestState.Passed, ""); _feedback.TestFinished(test); _feedback.TestFinished(test); _feedback.TestFinished(test); _feedback.TestFinished(test); _feedback.TestFinished(test); _feedback.TestFinished(test); Thread.Sleep(1100); _feedback.TestFinished(test); _bus.AssertWasCalled(x => x.Publish<LiveTestStatusMessage>(null), x => x.IgnoreArguments()); }
public void OnSpecificationEnd(SpecificationInfo specification, Machine.Specifications.Result result) { var test = new TestResult( "MSpec", _assembly, specification.ContainingType, DateTime.Now.Subtract(_start).TotalMilliseconds, specification.ContainingType, specification.ContainingType, getState(result.Status), getMessage(result.Exception)); test.AddStackLines(getStackLines(result.Exception)); _results.Add(test); if (_feedback != null) _feedback.TestFinished(test); }
private void onSpecificationEnd(object specification, object result) { var test = new TestResult( "MSpec", _assembly, specification.Get<string>("ContainingType"), DateTime.Now.Subtract(_start).TotalMilliseconds, specification.Get<string>("ContainingType"), specification.Get<string>("ContainingType"), getState(result.Get<object>("Status").ToString()), getMessage(result.Get<object>("Exception"))); test.AddStackLines(getStackLines(result.Get<object>("Exception"))); _results.Add(test); if (_feedback != null) _feedback.TestFinished(test); }
public void Should_publish_status_every_150ms() { _cache.Stub(x => x.Failed).Return(new TestItem[] { }); var test = new AutoTest.TestRunners.Shared.Results.TestResult("", "", "", 0, "Passing test", AutoTest.TestRunners.Shared.Results.TestState.Passed, ""); _feedback.TestStarted(""); _feedback.TestStarted(""); _feedback.TestStarted(""); _feedback.TestStarted(""); _feedback.TestStarted(""); _feedback.TestStarted(""); Thread.Sleep(70); _feedback.TestStarted(""); _bus.AssertWasCalled(x => x.Publish <LiveTestStatusMessage>(null), x => x.IgnoreArguments()); }
private TestResult BuildTestResult(RunResult res) { var message = BuildMessage(res); var state = res.Passed ? TestState.Passed : TestState.Failed; var result = new TestResult("SimpleTesting", res.FoundOnMemberInfo.DeclaringType.Assembly.FullName, res.FoundOnMemberInfo.DeclaringType.Name, 0, res.FoundOnMemberInfo.DeclaringType.FullName + "." + res.FoundOnMemberInfo.Name, res.Name, state, message ); if(state == TestState.Failed) { result.AddStackLines(getStackLines(res.Thrown)); } return result; }
private IEnumerable<TestResult> runAllTests(Assembly assembly) { TestResult failresult = null; IEnumerable<RunResult> results = null; try { results = SimpleRunner.RunAllInAssembly(assembly); } catch (Exception ex) { failresult = new TestResult(Identifier, assembly.FullName, "", 0, "Error while running tests", TestState.Panic, getMessage(ex) + Environment.NewLine + Environment.NewLine); failresult.AddStackLines(getStackLines(ex)); } if (failresult != null) { yield return failresult; } else { if (results == null) yield break; foreach (var res in results) { yield return BuildTestResult(res); } } }
public void TestFinished(TestResult result) { }
public static void AddResults(TestResult result) { lock (_results) { _results.Add(result); } }
public static void CurrentDomainUnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) { var message = getException((Exception)args.ExceptionObject); // TODO: Seriously!? Firgure out what thread is causing the app domain unload exception if (!_arguments.CompatabilityMode && !args.ExceptionObject.GetType().Equals(typeof(System.AppDomainUnloadedException))) { var finalOutput = new TestResult("Any", "", "", 0, "An unhandled exception was thrown while running a test.", TestState.Panic, "This is usually caused by a background thread throwing an unhandled exception. " + "Most test runners run in clr 1 mode which hides these exceptions from you. If you still want to suppress these errors (not recommended) you can enable compatibility mode." + Environment.NewLine + Environment.NewLine + "To head on to happy land where fluffy bunnies roam freely painting green left right and center do so by passing the --compatibility-mode switch to the test " + "runner or set the <TestRunnerCompatibilityMode>true</TestRunnerCompatibilityMode> configuration option in " + "AutoTest.Net." + Environment.NewLine + Environment.NewLine + message); AddResults(finalOutput); } if (args.IsTerminating) { var writer = new ResultsXmlWriter(_results); writer.Write(_arguments.OutputFile); Write(" "); if (File.Exists(_arguments.OutputFile)) { Write("Test run result:"); Write(File.ReadAllText(_arguments.OutputFile)); } Environment.Exit(-1); } Thread.CurrentThread.IsBackground = true; Thread.CurrentThread.Name = "Dead thread"; lock (_haltedThreads) { _haltedThreads.Add(Thread.CurrentThread); } /*if (Thread.CurrentThread.ManagedThreadId != _mainThreadID) { while (true) Thread.Sleep(TimeSpan.FromHours(1)); }*/ }
private void getTest(XmlTextReader reader) { if (reader.NodeType == XmlNodeType.EndElement) { _results.Add(_currentTest); } else { _currentTest = new TestResult(); _currentTest.Runner = _currentRunner; _currentTest.Assembly = _currentAssembly; _currentTest.TestFixture = _currentFixture; _currentTest.State = getTestState(reader.GetAttribute("state")); _currentTest.DurationInMilliseconds = double.Parse(reader.GetAttribute("duration")); _currentTest.TestName = reader.GetAttribute("name"); } }
private TestResult getResult(RunSettings settings, IGrouping<Type, MethodInfo> fixture, celer.Core.RunResult x) { var result = new TestResult(Identifier, settings.Assembly.Assembly, fixture.Key.FullName, x.MillisecondsSpent, fixture.Key.FullName + "." + x.Test.Name, getState(x), getMessage(x)); result.AddStackLines(getStackLines(x.Exception)); return result; }
public static void CurrentDomainUnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) { var message = getException((Exception)args.ExceptionObject); var result = new TestResult("Any", "", "", 0, "An unhandled exception was thrown while running a test", TestState.Panic, message); AddResults(result); var writer = new ResultsXmlWriter(_results); writer.Write(_arguments.OutputFile); if (args.IsTerminating) Environment.Exit(-1); }
public static void CurrentDomainUnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) { var message = getException((Exception)args.ExceptionObject); if (Thread.CurrentThread.ManagedThreadId.Equals(_mainThreadID)) { var result = new TestResult("Any", "", "", 0, "An unhandled exception was thrown while running a test", TestState.Panic, message); AddResults(result); var writer = new ResultsXmlWriter(_results); writer.Write(_arguments.OutputFile); if (args.IsTerminating) Environment.Exit(-1); return; } if (!_arguments.CompatabilityMode) { var result = new TestResult( "Any", "", "", 0, string.Format("An unhandled exception was thrown from an app domain or a background thread while running a test (Thread: {0}}", Thread.CurrentThread.Name), TestState.Panic, message); AddResults(result); } Thread.CurrentThread.IsBackground = true; Thread.CurrentThread.Name = "Dead thread"; lock (_haltedThreads) { _haltedThreads.Add(Thread.CurrentThread); } while (true) Thread.Sleep(TimeSpan.FromHours(1)); }