public List<Test> GetTests(TestStatus testStatus = TestStatus.Ready) { using (var context = GetContext()) { return context.Tests.Where(t => t.Status == (byte)testStatus).ToList(); } }
private TestResult[] queryByStatus(TestStatus status) { var query = from t in _testResults where t.Status.Equals(status) select t; return query.ToArray(); }
public static void InvokeCurrentCallback(string testName, TestStatus status, ExceptionDetails exceptionDetails, string traceLog) { if (_currentCallback == null) return; _currentCallback(testName, status, exceptionDetails, traceLog); }
public StepRunnerEventArgs(Guid scenarioId, Guid criterionId, Guid stepId, DateTime now, double duration, TestStatus status, string screenShotUrl=null): this(scenarioId, criterionId,stepId,now) { Duration = duration; Status = status; ScreenShotUrl = screenShotUrl; }
public async Task<bool> Run() { this.Status = TestStatus.Running; if (this.TestStatusChanged != null) { this.TestStatusChanged(this, new TestStatusChangedEventArgs(this.Status)); } bool passed; try { passed = await this.execution(this); this.Status = passed ? TestStatus.Passed : TestStatus.Failed; this.AddLog("Test {0}", this.Status); } catch (Exception ex) { this.AddLog("Test failed with exception: {0}", ex); passed = false; this.Status = TestStatus.Failed; } if (this.TestStatusChanged != null) { this.TestStatusChanged(this, new TestStatusChangedEventArgs(this.Status)); } return passed; }
public ProjectFinishedRunning(Guid projectId, TestStatus status, DateTime finishedAt, string screenShotUrl) { ProjectId = projectId; Status = status; FinishedAt = finishedAt; ScreenShotUrl = screenShotUrl; }
public TestResult(TestStatus status, string name, string message, IStackLine[] stackTrace) { _status = status; _name = name; _message = message; _stackTrace = stackTrace; }
public ZumoTest(string name, TestExecution execution) { this.Name = name; this.Data = new Dictionary<string, object>(); this.logs = new List<string>(); this.execution = execution; this.Status = TestStatus.NotRun; }
public TestSuiteResult(TestStatus status, long timeTaken, uint total, uint passes, uint skipped) { Status = status; TimeTaken = timeTaken; Total = total; Passes = passes; Skipped = skipped; }
/// <summary> /// Default Constructor /// </summary> public TestedAttribute(string reference, string description, TestStatus status = TestStatus.Tested) { TestReference = reference; TestDescription = description; Status = status; if (status == TestStatus.Undocumented) throw new ArgumentException("TestStatus.Undocumented should not be used. This is for Audit purposes only."); }
public void Status_ConstructorWithTwoArguments_ReturnsConstructorArgumentStatus(TestStatus status) { // Arrange N/A ResultState resultState = new ResultState(status, string.Empty); Assert.AreEqual(status, resultState.Status); }
public ScenarioFinishedRunning(Guid projectId, Guid scenarioId, string scenarioName, TestStatus status, DateTime finishedAt, string screenShotUrl) { ProjectId = projectId; ScenarioId = scenarioId; ScenarioName = scenarioName; Status = status; FinishedAt = finishedAt; ScreenShotUrl = screenShotUrl; }
private static TestStepFinished GetTestStepFinished(TestStatus testStatus) { var testStepRun = new TestStepRun(new TestStepData("id", "name", "fullName", "testId")) { Step = new TestStepData("id", "name", "fullName", "testId") { IsTestCase = true }, Result = new TestResult(new TestOutcome(testStatus)) }; return new TestStepFinished(null, testStepRun); }
public CriterionFinishedRunning(Guid projectId, Guid scenarioId, Guid criterionId, TestStatus status, DateTime finishedAt, string screenShotUrl) { ProjectId = projectId; ScenarioId = scenarioId; CriterionId = criterionId; Status = status; FinishedAt = finishedAt; ScreenShotUrl = screenShotUrl; }
public void Reset() { this.logs.Clear(); this.Status = TestStatus.NotRun; if (this.TestStatusChanged != null) { this.TestStatusChanged(this, new TestStatusChangedEventArgs(this.Status)); } }
/// <summary> /// Adds an error to the test result error collection. /// </summary> /// <param name="message">The error message.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="message"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentException"> /// Thrown if <paramref name="message"/> is an empty string. /// </exception> public void AddError(string message) { { Lokad.Enforce.Argument(() => message); Lokad.Enforce.Argument(() => message, Lokad.Rules.StringIs.NotEmpty); } m_Errors.Add(message); m_Status = TestStatus.Failed; }
private void AssertTestResult(string expectedOutput, TestStatus expectedStatus, Type fixtureType, string methodName) { CodeReference codeReference = CodeReference.CreateFromMember(fixtureType.GetMethod(methodName)); TestStepRun run = Runner.GetPrimaryTestStepRun(codeReference); Assert.AreEqual(expectedStatus, run.Result.Outcome.Status); string actualOutput = run.TestLog.GetStream(MarkupStreamNames.Default).ToString(); Assert.AreEqual(expectedOutput, actualOutput); }
private string checkbox(TestStatus status) { switch(status) { case TestStatus.Idle: return "[ ]"; case TestStatus.WaitingForDependencies: return "[ ]"; case TestStatus.Running: return "[.]"; case TestStatus.FinishedError: return "[!]"; case TestStatus.FinishedSuccessfully: return "[X]"; default: throw new ApplicationException("unknown status:" + status); } }
public void Expand(TestStatus state) { BeginUpdate(); CollapseAll(); foreach (TreeNodeAdv node in AllNodes) ExpandNode(node, state); EndUpdate(); }
protected StepFinishedRunning(Guid projectId, Guid storyId, Guid scenarioId, Guid criterionId, Guid stepId, TestStatus testStatus, DateTime finishedAt, double duration, string screenShotUrl) { ProjectId = projectId; StoryId = storyId; ScenarioId = scenarioId; CriterionId = criterionId; StepId = stepId; Status = testStatus; FinishedAt = finishedAt; Duration = duration; ScreenShotUrl = screenShotUrl; }
private TestResult GetTestResult(MethodGroup methodGroup, TestStatus status, string reason = null) { return new TestResult { Assembly = _assembly.Name, Class = methodGroup.Class, Method = methodGroup.Method, Namespace = methodGroup.FullName, Reason = reason, Status = status, Test = string.Format("{0}.{1}", methodGroup.Class, methodGroup.Method) }; }
private async Task ReportTestProgressAsync(TestStatus status, ExceptionDetails exceptionDetails = null) { await TaskEx.Run(() => { using (var client = TestCallbackClient.Create()) { client.ReportTestProgress("ThisTest", status, exceptionDetails, TestLog.Current.MessageDetails); } }); }
private Shared.Results.TestState convertState(TestStatus testStatus) { switch (testStatus) { case TestStatus.Passed: return(Shared.Results.TestState.Passed); case TestStatus.Inconclusive: case TestStatus.Skipped: return(Shared.Results.TestState.Ignored); case TestStatus.Failed: return(Shared.Results.TestState.Failed); } return(Shared.Results.TestState.Panic); }
public void AbortTest(string reason) { _testStatus = TestStatus.ABORTED; System.Diagnostics.StackTrace sTrace = new System.Diagnostics.StackTrace(); Tracer.Write(Tracer.TraceLevel.FATAL, "TEST ABORTED: " + reason, "TEST"); Tracer.Write(Tracer.TraceLevel.FATAL, "STACK TRACE: " + sTrace.ToString(), "TEST"); _xmlLog.RegisterTestAborted(reason); _xmlLog.RegisterTestExiting(); foreach (var testPlatform in GetClientsList()) { testPlatform.IEX.LogComment(reason, isBold: true, size: "12", colour: "Red"); testPlatform.IEX.LogComment("TEST ABORTED!", isBold: true, size: "14", colour: "Red"); } }
private static TestOutcome GetOutcome(TestStatus testStatus) { switch (testStatus) { case TestStatus.Passed: return TestOutcome.Passed; case TestStatus.Failed: return TestOutcome.Failed; case TestStatus.Skipped: return TestOutcome.Skipped; case TestStatus.Inconclusive: return TestOutcome.NotFound; default: throw new ArgumentException("Unexpected test status"); } }
public static Color GetColorForApproval(TestStatus status) { switch (status) { case TestStatus.NeverRun: return Color.LightBlue; case TestStatus.NeverApproved: return Color.Yellow; case TestStatus.Approved: return Color.Green; case TestStatus.Failed: return Color.Red; } return Color.White; }
public void ThrowPendingError(TestStatus testStatus, string message) { switch (RuntimeConfiguration.Current.MissingOrPendingStepsOutcome) { case MissingOrPendingStepsOutcome.Inconclusive: unitTestRuntimeProvider.TestInconclusive(message); break; case MissingOrPendingStepsOutcome.Ignore: unitTestRuntimeProvider.TestIgnore(message); break; default: if (testStatus == TestStatus.MissingStepDefinition) throw GetMissingStepDefinitionError(); throw GetPendingStepDefinitionError(); } }
public void AssertExceptionOutcome(string testMethodName, TestStatus expectedOutcomeStatus, string expectedOutcomeCategory, string expectedLogOutput) { var run = Runner.GetPrimaryTestStepRun(CodeReference.CreateFromMember(typeof(AssertExceptionSample).GetMethod(testMethodName))); Assert.Multiple(() => { Assert.IsNotNull(run); Assert.AreEqual(expectedOutcomeStatus, run.Result.Outcome.Status); Assert.AreEqual(expectedOutcomeCategory, run.Result.Outcome.Category); if (expectedLogOutput != null) AssertLogContains(run, expectedLogOutput, MarkupStreamNames.Failures); }); }
void AsyncCreateTests(object ob) { TestStatus newStatus = TestStatus.Ready; try { LoadData loadData = (LoadData)ob; if (loadData.Error != null) { newStatus = TestStatus.LoadError; return; } Tests.Clear(); if (loadData.Info == null) { oldList = new UnitTest [0]; return; } FillTests(loadData.Info); // If the async loader has loaded a cache, reuse it. if (loadData.InfoCache != null) { testInfoCache = loadData.InfoCache; } testInfoCache.SetInfo(AssemblyPath, loadData.Info); } catch (Exception ex) { LoggingService.LogError(ex.ToString()); newStatus = TestStatus.LoadError; } finally { lock (locker) { Status = newStatus; Monitor.PulseAll(locker); } OnTestChanged(); } }
public ActionResult TestsResaults(int?page, Guid?testCaseGuid, Guid?statusGuid) { TestsRepository testsRepo = new TestsRepository(); ApplicationUserRepository <Company> userRepo = new ApplicationUserRepository <Company>(); Company company = userRepo.GetByUserName(User.Identity.Name); TestCaseRepository testCaseRepo = new TestCaseRepository(); ViewBag.TestCases = testCaseRepo.GetAllForCompany(company); TestStatusRepository statusRepo = new TestStatusRepository(); ViewBag.Statuses = statusRepo.GetAll(); int itemsOnPage = 20; int pg = page ?? 1; int startIndex = (pg * itemsOnPage) - itemsOnPage; TestCase testCase = null; if (testCaseGuid != null) { testCase = testCaseRepo.GetById((Guid)testCaseGuid); ViewBag.TestCase = testCase; } TestStatus testStatus = null; if (statusGuid != null) { testStatus = statusRepo.GetById((Guid)statusGuid); ViewBag.Status = testStatus; } IList <DataAccess.Model.Tests.Tests> testses = testsRepo.GetTestsForCompany(company, out int totalTests, out int filteredCount, testCase, testStatus, startIndex, itemsOnPage); ViewBag.Pages = (int)Math.Ceiling((double)totalTests / (double)itemsOnPage); ViewBag.CurrentPage = pg; if (Request.IsAjaxRequest()) { return(PartialView(testses)); } return(View(testses)); }
public void TestTextColorPropertyReturnsColorForResultState([Values] TestStatus status) { TestResultForTest result = new TestResultForTest(); result.ResultState = new ResultState((TestStatus)(-1)); Color expected = Color.Black; ResultState state = ResultState.NotRunnable; switch (status) { case TestStatus.Inconclusive: state = ResultState.Inconclusive; expected = Color.Purple; break; case TestStatus.Skipped: state = ResultState.Ignored; expected = Color.Blue; break; case TestStatus.Passed: state = ResultState.Success; expected = Color.Green; break; case TestStatus.Warning: state = ResultState.Warning; expected = Color.Orange; break; case TestStatus.Failed: state = ResultState.Failure; expected = Color.Red; break; default: Assert.Fail($"This status {status} is not supported."); break; } result.ResultState = state; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(expected, test.TextColor); }
private void DeactivateControls() { gbVisibleTime.Enabled = false; gBAdditionOptions.Enabled = false; gBMultiplicationOption.Enabled = false; gBSeriesCount.Enabled = false; gBTrainType.Enabled = false; tBTestWord.Text = string.Empty; tBTestWord.ReadOnly = false; panelCalculationSeries.Controls.Clear(); lblCheckResult.Visible = false; globalStatus = TestStatus.IsGoing; }
public static InlineImage ToHtmlLogIcon(this TestStatus it) { switch (it) { case TestStatus.Pass: return(Test.Log.PassIcon); case TestStatus.Fail: return(Test.Log.FailIcon); case TestStatus.Subjective: return(Test.Log.InfoIcon); default: return(Test.Log.StopSignIcon); } }
private static Platform.Color GetColor(TestStatus status, ShadeColors colors) { switch (status) { //case TestStatus.Pending: default: return Platform.Color.ConvertFrom(CodeRush.VSSettings.BackgroundColor); case TestStatus.Ignored: return colors.SkippedColor; case TestStatus.Passed: //case TestStatus.PassedWithChanges: return colors.PassedColor; case TestStatus.Failure: //case TestStatus.FailedWithChanges: return colors.FailedColor; } }
// Finish test // ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- IEnumerator FinishTestRoutine(string uri, int sessionid) { m_operating = true; uri += "/post/general/finishtest"; WWWForm form = new WWWForm(); form.AddField("sessionid", sessionid); UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Post(uri, form); yield return(www.SendWebRequest()); DebugResults(www); testStatus = null; m_operating = false; }
public static bool IsEqualOrMoreSevere(this TestStatus status, TestStatus statusToCompareTo) { switch (status) { case TestStatus.Error: return(true); case TestStatus.Warning: return(statusToCompareTo != TestStatus.Error); case TestStatus.Pass: return(statusToCompareTo == TestStatus.Pass); default: return(false); } }
public void AfterEachTest() { TestStatus = TestContext.CurrentContext.Result.Outcome.Status; var stackTrace = string.IsNullOrEmpty(TestContext.CurrentContext.Result.StackTrace) ? "" : TestContext.CurrentContext.Result.StackTrace; var message = string.IsNullOrEmpty(TestContext.CurrentContext.Result.Message) ? "" : TestContext.CurrentContext.Result.Message; switch (TestStatus) { case TestStatus.Failed: LogStatus = Status.Fail; break; case TestStatus.Inconclusive: LogStatus = Status.Warning; break; case TestStatus.Skipped: LogStatus = Status.Skip; break; case TestStatus.Passed: LogStatus = Status.Pass; break; default: LogStatus = Status.Pass; break; } Screenshot img = WebDriver.TakeScreenshot(); var imgPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\" + Guid.NewGuid(); img.SaveAsFile(imgPath, ScreenshotImageFormat.Png); ExtentTest.Log(LogStatus, "<strong>" + LogStatus + TestStatus + "</strong><a href='" + imgPath + "' data-featherlight='image' style='display: block;'><img src='" + imgPath + "' height='200' width='350' style='display: block;'></ a >"); ExtentTest.AssignDevice(DriverType.ToString()); ExtentReports.Flush(); WebDriver.Close(); WebDriver.Quit(); }
private static bool WritePassedTestsToFile_(TestContext tc, TestStatus status) { try { File.AppendAllText(excludedTestsListFilename_, ""); if (status == TestStatus.Passed) { File.AppendAllLines(excludedTestsListFilename_, new string[] { tc.Test.FullName }); } return(true); } catch (Exception ex) { CommonUtils.LogExceptionStackTrace(logger_, Stage.TestFramework, ex); return(false); } }
/// <summary> /// Handler for test result callbacks. /// </summary> /// <param name="status">The current <see cref="TestStatus"/>.</param> /// <param name="message">The message applicable for this result.</param> void TestResultHandler(TestStatus status, string message) { switch (status.Operation) { case TestOperation.Initialising: Console.WriteLine("Testing"); break; case TestOperation.Complete: Console.WriteLine("Testing complete"); break; case TestOperation.EntryHeader: // Not an error if message is null. if (message == null) { Console.Write("{0} - ", status.Entry.Name); } else { Console.WriteLine(message); } break; case TestOperation.EntryData: if (message != null) { Console.WriteLine(message); } break; case TestOperation.EntryComplete: if (status.EntryValid) { Console.WriteLine("OK"); } break; case TestOperation.MiscellaneousTests: if (message != null) { Console.WriteLine(message); } break; } }
private TestResult MapStatus(TestStatus status) { switch (status) { case TestStatus.FAILURE: return(TestResult.Failed); case TestStatus.SUCCESS: return(TestResult.Success); case TestStatus.UNKNOWN: return(TestResult.Inconclusive); default: throw new NotSupportedException("Not supported test status: " + status); } }
public static FeatureStatus ToFeatureStatus(this TestStatus status) { switch (status) { case TestStatus.Passed: return(FeatureStatus.Supported); case TestStatus.Failed: return(FeatureStatus.NotSupported); case TestStatus.NotDetected: return(FeatureStatus.Undefined); default: throw new ArgumentException("Unknown TestStatus", "status"); } }
public override void DoRow(Parse theRow) { try { if (theRow.Parts.Size != headerCells.Size) { throw new FitFailureException(String.Format("Row should be {0} cells wide.", headerCells.Size)); } Processor.ExecuteWithThrow(this, new CellRange(headerCells), new CellRange(theRow.Parts), theRow.Parts); } catch (MemberMissingException e) { TestStatus.MarkException(headerCells, e); throw new IgnoredException(); } catch (Exception e) { TestStatus.MarkException(theRow.Parts, e); } }
public static Color GetColor(this TestStatus status) { switch (status) { case TestStatus.Passed: return(Color.Green); case TestStatus.Failed: return(Color.Red); case TestStatus.NotDetected: return(Color.Gray); default: throw new ArgumentOutOfRangeException("status"); } }
public bool FinalCheck(TestStatus testStatus) { if (myColumnsUsed == null) { return(true); } for (int column = 0; column < myHeaderRow.Branches.Count; column++) { if (myColumnsUsed[column]) { continue; } testStatus.MarkException(myHeaderRow.Branches[column].Value, new FitFailureException(String.Format("Column '{0}' not used.", myHeaderRow.Branches[column].Value.Text))); return(false); } return(true); }
public CellProcessorBase(Memory memory, CellOperators operators) : base(memory) { TestStatus = new TestStatus(); CallStack = new CallStack(); this.operators = operators; operators.Processor = this; Memory.GetItem <Symbols>(); Memory.GetItem <Procedures>(); Memory.Add(new FitEnvironment() { RunTest = new RunTestDefault(), DecorateElement = new DecorateElementDefault() }); ApplicationUnderTest.AddNamespace("fitSharp.Fit.Fixtures"); }
private void ProcessCells(Parse cells, Func <Binding, bool> bindingFilter) { int i = 0; for (Parse cell = cells; cell != null && i < ColumnBindings.Length; cell = cell.More, i++) { if (!bindingFilter(ColumnBindings[i])) { continue; } try { DoCell(cell, i); } catch (Exception e) { TestStatus.MarkException(cells, e); } } }
/// <summary> /// Executes one test method /// </summary> /// <param name="method">The parameterless method</param> /// <param name="instance">The test class instance</param> /// <param name="testStatus">The test result</param> /// <param name="testException">The exception that the test method has thrown or null if the test has passed without a failure</param> private static void ExecuteTestMethod(MethodInfo method, object instance, out TestStatus testStatus, out Exception testException) { try { method.Invoke(instance, null); testStatus = TestStatus.Passed; testException = null; } catch (Exception exception) { if (exception.InnerException != null) { exception = exception.InnerException; } testStatus = TestStatus.Failed; testException = exception; } }
public void FilterStatus(TestStatus testStatus) { switch (testStatus) { case TestStatus.Passed: testExplorerModel.FilterPassed.Value = !testExplorerModel.FilterPassed; break; case TestStatus.Failed: testExplorerModel.FilterFailed.Value = !testExplorerModel.FilterFailed; break; case TestStatus.Inconclusive: testExplorerModel.FilterInconclusive.Value = !testExplorerModel.FilterInconclusive; break; } eventAggregator.Send(this, new FilterTestStatusEvent(testStatus)); }
public void Client_times_out_on_long_auth() { Server.Config.RequireAuthentication = true; Client.Config.ConnectionTimeout = 100; Client.Closed += (sender, e) => { if (e.CloseReason != SocketCloseReason.TimeOut) { LastException = new Exception("Client was not notified that the authentication failed."); } TestStatus.Set(); }; Server.Authenticate += (sender, e) => { Thread.Sleep(500); }; StartAndWait(true, 5000, true); }
/// <summary> /// Look up the method location in the test results. If found use the test results to pick the background color /// </summary> /// <param name="location"></param> /// <returns></returns> private Color GetBackgroundColor(TestStatus status) { switch (status) { case TestStatus.Unknown: default: return(CodeRush.VSSettings.BackgroundColor); case TestStatus.Skipped: return(SkippedColor); case TestStatus.Passed: return(PassedColor); case TestStatus.Failed: return(FailedColor); } }
//Disabled//[Row("ExpectSkippedWhenThrowArgNullExAndArgNullExIsSkippedAndArgExIsExpected", TestStatus.Skipped, null, null, null)] //Disabled//[Row("ExpectSkippedWhenThrowArgExAndArgExIsSkippedAndArgNullExIsExpected", TestStatus.Skipped, null, null, null)] //Disabled//[Row("ExpectInconclusiveFromOrder2WhenThrowArgExAndArgNullExIsSkippedAndArgExIsInconclusiveAndNotImplExIsPendingAndNotSuppExIsIgnoredAndInvOpExIsExpected", TestStatus.Inconclusive, null, null)] public void CatchExceptionOutcome(string testMethodName, TestStatus expectedOutcomeStatus, string expectedOutcomeCategory, string logStreamName, string expectedLogOutput) { var run = Runner.GetPrimaryTestStepRun(CodeReference.CreateFromMember(typeof(CatchExceptionSample).GetMethod(testMethodName))); Assert.Multiple(() => { Assert.IsNotNull(run); Assert.AreEqual(expectedOutcomeStatus, run.Result.Outcome.Status); Assert.AreEqual(expectedOutcomeCategory, run.Result.Outcome.Category); if (expectedLogOutput != null) { AssertLogContains(run, expectedLogOutput, logStreamName ?? MarkupStreamNames.Failures); } }); }
void ProcessRestOfTable(Interpreter theFixture, Parse theRestOfTheRows) { var restOfTable = new Parse("table", "", theRestOfTheRows, null); theFixture.Processor = Processor; var fixture = theFixture as Fixture; if (fixture != null) { fixture.Prepare(this, restOfTable); } try { ExecuteStoryTest.DoTable(restOfTable, theFixture, false); } catch (Exception e) { TestStatus.MarkException(theRestOfTheRows.Parts, e); } }
private static bool WriteFailedTestsToFile_(TestContext tc, TestStatus status) { try { File.AppendAllText(includedTestsListFilename, ""); if (status != TestStatus.Passed) { File.AppendAllLines(includedTestsListFilename, new string[] { tc.Test.FullName }); } return(true); } catch (Exception ex) { string s = $"{DateTimeOffset.Now:yyyy'-'MM'-'dd HH':'mm':'ss.fff} - Eyes: Test Report Error: {ex}"; TestContext.Progress.WriteLine(s); return(false); } }
public void TearDownDashboardTestFixture() { VerifyExpectedErrorOccurred(); TestStatus status = TestContext.CurrentContext.Result.Outcome.Status; if (status == TestStatus.Failed) { this.CaptureScreenshot(); this.CaptureDom(); DriverSingleton.Dispose(); } else { CloseAllOpenedReports(); } TestRetryCounter.SetPreviousTestName(); }
private void WriteStatusResults(TextWriter writer, TestSuiteResult result, TestStatus status, string header) { if (!result.InnerResults.Any(r => r.Status == status)) { return; } writer.WriteLine(header); writer.WriteHorizontalRuler(); var i = 1; foreach (var testMethodResult in result.InnerResults.Where(r => r.Status == status).Cast <TestMethodResult>().OrderBy(r => r.StartTime)) { writer.Write(i++ + ". "); testMethodResultWriter.Write(writer, testMethodResult); } writer.WriteLine(); }
private static void CountCategories(TestStepRun run, TestStatus status, IDictionary <string, int> aggregator) { if (run.Children.Count == 0) { if (run.Result.Outcome.Status == status && !String.IsNullOrEmpty(run.Result.Outcome.Category)) { string category = run.Result.Outcome.Category; int count; aggregator[category] = 1 + (aggregator.TryGetValue(category, out count) ? count : 0); } return; } foreach (TestStepRun child in run.Children) { CountCategories(child, status, aggregator); } }
public void TearDown() { TestStatus testStatus = TestContext.CurrentContext.Result.Outcome.Status; if (testStatus == TestStatus.Passed) { extentTest.Log(Status.Pass, "<pre>" + TestContext.CurrentContext.Test.Name + " Passed</pre>"); } else if (testStatus == TestStatus.Failed) { var stackTrace = "<pre>" + TestContext.CurrentContext.Result.StackTrace + "</pre>"; var errorMessage = TestContext.CurrentContext.Result.Message; GetScreenShot.GetInstance().Capture(this.WebDriver, TestContext.CurrentContext.Test.Name); extentTest.AddScreenCaptureFromPath(GetScreenShot.GetInstance().ScreenshotPath + TestContext.CurrentContext.Test.Name + ".png"); extentTest.Log(Status.Fail, stackTrace + errorMessage); } ElementAccessors.Wait(1); this.WebDriver.Quit(); }
public void MergeStepStatistics(TestStatus status, bool isTestCase) { TestStepRun testStepRun = new TestStepRun(new TestStepData("stepId", "stepName", "fullName", "testId")); testStepRun.Result.Outcome = new TestOutcome(status); testStepRun.Result.AssertCount = 3; testStepRun.Step.IsTestCase = isTestCase; stats.MergeStepStatistics(testStepRun); Assert.AreEqual(3, stats.AssertCount); Assert.AreEqual(1, stats.StepCount); Assert.AreEqual(isTestCase ? 1 : 0, stats.TestCount); Assert.AreEqual(isTestCase && status != TestStatus.Skipped ? 1 : 0, stats.RunCount); Assert.AreEqual(isTestCase && status == TestStatus.Skipped ? 1 : 0, stats.SkippedCount); Assert.AreEqual(isTestCase && status == TestStatus.Passed ? 1 : 0, stats.PassedCount); Assert.AreEqual(isTestCase && status == TestStatus.Inconclusive ? 1 : 0, stats.InconclusiveCount); Assert.AreEqual(isTestCase && status == TestStatus.Failed ? 1 : 0, stats.FailedCount); Assert.AreEqual(isTestCase ? 1 : 0, stats.GetOutcomeCount(new TestOutcome(status))); }
/// <summary> /// Times the action passed in and sets status in case of exceptions. /// </summary> /// <param name="action">The method that is being timed.</param> /// <param name="timeVal">The holder for the timing</param> /// <param name="status">The status to set in the event of an exception.</param> /// <param name="testable">The testable object that provides message buffers.</param> /// <returns></returns> public static bool Time( Func<bool> action, ref long timeVal, ref TestStatus status, ITestable testable) { try { Stopwatch stopwatch = Stopwatch.StartNew(); bool success = action.Invoke(); timeVal = stopwatch.Elapsed.Seconds; //TODO - log Milliseconds; or seconds switch. return success; } catch (Exception e) { new MsgBufferWriter(testable).Write(e.Message); VerboseMsgWriter writer = new VerboseMsgWriter(testable); writer.Write(e.GetType().Name); DumpStackTrace(e, writer); status = TestStatus.FAIL_BY_EXCEPTION; return false; } }
/// <summary> /// verifies that the specified test method has been run or not, and /// that it gave the expected result. /// </summary> /// <param name="groupName">Name of the group which contains the test method.</param> /// <param name="fixtureType">Type of the sample fixture which must be run.</param> /// <param name="testMethodName">Name of evaluated test method.</param> /// <param name="expectedTestStatus">Expected test status. If <see cref="TestStatus.Inconclusive" /> /// is specified, the test method is expected to not run.</param> protected TestStepRun VerifySampleContract(string groupName, Type fixtureType, string testMethodName, TestStatus expectedTestStatus) { var contractName = String.Format("/{0}/{1}/", GetType().Name, fixtureType.Name); var all = Report.TestPackageRun.AllTestStepRuns.Where(x => x.Step.IsPrimary).Select(x => x.Step.FullName).ToArray(); var contracts = Report.TestPackageRun.AllTestStepRuns .Where(x => x.Step.IsPrimary && x.Step.FullName.Contains(contractName) && x.Step.FullName.EndsWith(groupName)); Assert.IsNotEmpty(contracts, "No contract named '...{0}' found in the fixture.", contractName); TestStepRun first = null; foreach (TestStepRun contract in contracts) { var runs = contract.Children.Where(x => x.Step.FullName.EndsWith(testMethodName)); foreach (TestStepRun run in runs) { Assert.IsNotNull(run); Assert.AreEqual(expectedTestStatus, run.Result.Outcome.Status); if (first == null) { first = run; } } } if (expectedTestStatus == TestStatus.Inconclusive) { Assert.IsNull(first); } else { Assert.IsNotNull(first, "No test method named '{0}' found.", testMethodName); } return first; }