Example #1
0
        public static Color GetColor(this TestStatus status)
        {
            switch (status)
            {
            case TestStatus.Running:
                return(Color.Yellow);

            case TestStatus.Failed:
            case TestStatus.FailedWithException:
            case TestStatus.Timeout:
                return(Color.LightCoral);

            case TestStatus.CompleteButUnknown:
            case TestStatus.Inconclusive:
            case TestStatus.Unknown:
                return(Color.LightGoldenrodYellow);

            case TestStatus.Passed:
                return(Color.PaleGreen);

            case TestStatus.Skipped:
                return(Color.LightGray);

            case TestStatus.AwaitingRun:
                return(Color.White);

            default:
                throw new Exception("Can't determine the color for " + status.ToString());
            }
        }
Example #2
0
        string NormalizeTestStatus(TestStatus status)
        {
            string returnValue = default(string);

            switch (status)
            {
            case ALMEntity.TestStatus.Blocked:
            case ALMEntity.TestStatus.Failed:
            case ALMEntity.TestStatus.Passed:
                returnValue = status.ToString();
                break;

            case ALMEntity.TestStatus.NA:
                returnValue = "N/A";
                break;

            case ALMEntity.TestStatus.Not_Completed:
                returnValue = "Not Completed";
                break;

            case ALMEntity.TestStatus.No_Run:
                returnValue = "No Run";
                break;
            }

            return(returnValue);
        }
Example #3
0
        public static int GetListSortOrder(this TestStatus status)
        {
            switch (status)
            {
            case TestStatus.Running:
                return(0);

            case TestStatus.Failed:
            case TestStatus.FailedWithException:
            case TestStatus.Timeout:
                return(1);

            case TestStatus.CompleteButUnknown:
            case TestStatus.Inconclusive:
            case TestStatus.Unknown:
                return(2);

            case TestStatus.Passed:
                return(3);

            case TestStatus.Skipped:
                return(4);

            case TestStatus.AwaitingRun:
                return(5);

            default:
                throw new Exception("Can't determine the sort order for " + status.ToString());
            }
        }
        private string FormatCountWithCategories(TestStatus status)
        {
            var output = new StringBuilder();

            output.Append(CountPerStatus(status) + " " + status.ToString().ToLower());
            var categories = CountPerCategory(status);

            if (categories.Count > 0)
            {
                output.Append(" (");
                bool first = true;

                foreach (var pair in categories)
                {
                    if (!first)
                    {
                        output.Append(", ");
                    }

                    output.Append(pair.Value + " " + pair.Key);
                    first = false;
                }

                output.Append(")");
            }

            return(output.ToString());
        }
Example #5
0
        public override void AfterTest(ITest test)
        {
            Console.WriteLine("Completed at {0:hh:mm:ss}", DateTime.Now);

            string     message = TestContext.CurrentContext.Result.Message;
            TestStatus status  = TestContext.CurrentContext.Result.Outcome.Status;

            Console.WriteLine("Status:      {0}\n", status.ToString());
            if (status != TestStatus.Passed)
            {
                Console.WriteLine(message);
            }
        }
Example #6
0
        public void UpdateTestStatus(TestContext.ResultAdapter result, TestStatus status = TestStatus.None)
        {
            if (status == TestStatus.None)
            {
                Result.Status       = result.Outcome.Status.ToString();
                Result.StackTrace   = result.StackTrace;
                Result.ErrorMessage = result.Message;
            }
            else
            {
                Result.Status = status.ToString();
            }

            Base.MongoDb.UpdateResult(this);
            Base._testRun.UpdataResults();
        }
Example #7
0
        /// <summary>
        /// Marks a test corresponding to the given session ID with the test status supplied.
        /// This method is used to mark tests as "pass" or "fail", based on what occurs in the ADFS environment.
        /// </summary>
        /// <param name="sessionId"></param>
        /// <param name="status"></param>
        public static void MarkTest(string sessionId, TestStatus status)
        {
            try
            {
                string url     = $"https://api.browserstack.com/";
                var    handler = new HttpClientHandler {
                    Credentials = AuthCredential
                };
                HttpClient client = new HttpClient(handler);
                client.BaseAddress = new Uri(url);

                // Create the data to PUT
                MarkTestData data = new MarkTestData();
                data.status = status.ToString();
                var output = JsonConvert.SerializeObject(data);

                var inputMessage = new HttpRequestMessage
                {
                    Content = new StringContent(output, Encoding.UTF8, "application/json")
                };
                inputMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage message = client.PutAsync($"automate/sessions/{sessionId}.json", inputMessage.Content).Result;

                if (message.IsSuccessStatusCode)
                {
                    Console.WriteLine("Test marked successfully");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"Failed to mark test {sessionId} with status {status}.");
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
        }
        /// <summary>
        /// TestCase results
        /// </summary>
        /// <param name="testStatus"></param>
        public void TestCaseResults(TestContext testContext)
        {
            TestStatus    testStatus    = testContext.Result.Outcome.Status;
            ResultAdapter resultAdapter = testContext.Result;

            object[]      endTestCaseParameterArray;
            List <string> testResults = new List <string>();
            TestResult    testResult  = TestResult.Inconclusive;

            Type                 myClass = Assembly.GetCallingAssembly().GetType(className);
            MethodInfo           EndOfTestCaseExecution = myClass.GetMethod("EndOfTestCaseExecution");
            TestBaseClassService myObj = (TestBaseClassService)Activator.CreateInstance(myClass);

            try
            {
                if (testStatus == TestStatus.Passed)
                {
                    if (Initialize.DisplayExecutionTimeInLogger)
                    {
                        watch.Stop();
                        timeElapsed = watch.ElapsedMilliseconds.ToString();
                    }

                    //Logging testcase details after pass
                    ContextLogger.LogAfterTestCasePass(moduleName, className, testCaseName, timeElapsed, testStatus.ToString());
                    endTestCaseParameterArray = new object[] { moduleName, className, testCaseName, true };
                    EndOfTestCaseExecution.Invoke(myObj, endTestCaseParameterArray);
                    testResult = TestResult.Passed;
                }

                else if (testStatus == TestStatus.Failed)
                {
                    //Logging if test case fails
                    if (Initialize.DisplayExecutionTimeInLogger)
                    {
                        watch.Stop();
                        timeElapsed = watch.ElapsedMilliseconds.ToString();
                    }

                    //Logging testCase details after fails
                    ContextLogger.LogAfterTestCaseFails(moduleName, className, testCaseName, testDataService.TestData, timeElapsed, testStatus.ToString());
                    endTestCaseParameterArray = new object[] { moduleName, className, testCaseName, false };
                    EndOfTestCaseExecution.Invoke(myObj, endTestCaseParameterArray);
                    testResult = TestResult.Failed;
                    testResults.Add(resultAdapter.Message);
                    testResults.Add(resultAdapter.StackTrace);
                }
                else if (testStatus == TestStatus.Skipped)
                {
                    //Logging if test case fails
                    if (Initialize.DisplayExecutionTimeInLogger)
                    {
                        watch.Stop();
                        timeElapsed = watch.ElapsedMilliseconds.ToString();
                    }

                    //Logging testCase details after fails
                    ContextLogger.LogAfterTestCaseSkipped(moduleName, className, testCaseName, timeElapsed, testStatus.ToString());
                    endTestCaseParameterArray = new object[] { moduleName, className, testCaseName, false };
                    EndOfTestCaseExecution.Invoke(myObj, endTestCaseParameterArray);
                    testResult = TestResult.Skipped;
                    testResults.Add(resultAdapter.Message);
                }
                else if (testStatus == TestStatus.Inconclusive)
                {
                    if (Initialize.DisplayExecutionTimeInLogger)
                    {
                        watch.Stop();
                        timeElapsed = watch.ElapsedMilliseconds.ToString();
                    }

                    //Logging testCase details after fails
                    ContextLogger.LogAfterTestCaseInConclusive(moduleName, className, testCaseName, timeElapsed, testStatus.ToString());
                    endTestCaseParameterArray = new object[] { moduleName, className, testCaseName, false };
                    EndOfTestCaseExecution.Invoke(myObj, endTestCaseParameterArray);
                    testResult = TestResult.Inconclusive;
                }
            }
            catch (IgnoreException ex)
            {
                //Logging testCase details after fails
                ContextLogger.LogAfterTestCaseSkipped(moduleName, className, testCaseName, timeElapsed, "Skipped" + ex.Message);
                endTestCaseParameterArray = new object[] { moduleName, className, testCaseName, false };
                EndOfTestCaseExecution.Invoke(myObj, endTestCaseParameterArray);
                testResult = TestResult.Skipped;
            }
            catch (Exception ex)
            {
                ContextLogger.LogIfException(moduleName, className, testCaseName, ex.Message);
                endTestCaseParameterArray = new object[] { moduleName, className, testCaseName, false };
                EndOfTestCaseExecution.Invoke(myObj, endTestCaseParameterArray);
                testResult = TestResult.Failed;
                if (testResults.Count == 0)
                {
                    testResults.Add("Test is executed with:" + testResult.ToString() + "status");
                }

                testResultService.InsertTestResults(testCaseName, testResult, testResults.ToArray());
            }
            finally
            {
                if (testResults.Count == 0)
                {
                    testResults.Add("Test is executed with:" + testResult.ToString() + "status");
                }

                testResultService.InsertTestResults(testCaseName, testResult, testResults.ToArray());
            }
        }
Example #9
0
        public void CreateStepResults(string gherkinKeyword, TestStatus stepStatus, string stepdescription = null)
        {
            switch (stepStatus)
            {
            case TestStatus.Pass:
                _scenario.CreateNode(new GherkinKeyword(gherkinKeyword), stepdescription).Pass(stepStatus.ToString());
                break;

            case TestStatus.Fail:
                _scenario.CreateNode(new GherkinKeyword(gherkinKeyword), stepdescription).Fail(stepStatus.ToString());
                break;

            case TestStatus.Error:
                _scenario.CreateNode(new GherkinKeyword(gherkinKeyword), stepdescription).Error(stepStatus.ToString());
                break;

            case TestStatus.Inconclusive:
                _scenario.CreateNode(new GherkinKeyword(gherkinKeyword), stepdescription).Skip(stepStatus.ToString());
                break;

            default:
                throw new NotSupportedException("Status not supported " + stepStatus);
            }
        }
Example #10
0
        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            string s = status.ToString();

            return(label == null || label.Length == 0 ? s : string.Format("{0}:{1}", s, label));
        }
Example #11
0
 private static NUnit.Framework.Interfaces.TestStatus ParseTestStatus(TestStatus testStatus)
 {
     return((NUnit.Framework.Interfaces.TestStatus)Enum.Parse(typeof(NUnit.Framework.Interfaces.TestStatus), testStatus.ToString()));
 }
Example #12
0
        private ListView GetProperListPerTestStatus(TestStatus testStatus)
        {
            switch (testStatus)
            {
            case TestStatus.AwaitingRun:
                return(list_TestsPending);

            case TestStatus.CompleteButUnknown:
            case TestStatus.Running:
            case TestStatus.Unknown:
            case TestStatus.Inconclusive:
                return(list_TestsInconclusive);

            case TestStatus.Failed:
            case TestStatus.FailedWithException:
            case TestStatus.Timeout:
                return(list_TestsFailed);

            case TestStatus.Passed:
                return(list_TestsPassed);

            case TestStatus.Skipped:
                return(list_TestsSkipped);

            default:
                throw new ArgumentException("Cannot figure out which list to assign a test to that is " + testStatus.ToString());
            }
        }
Example #13
0
        public virtual void RunTest(LoggingLevel preferredLoggingLevel, string rootDirectory)
        {
            if (CoarseGrind.KILL_SWITCH)
            {
                // Decline to run
            }
            else
            {
                bool setupResult = true;

                parentArtifactsDirectory = rootDirectory;
                Guid thisOutputIdentifier = Log.AddOutput(new TextOutputManager(
                                                              ArtifactsDirectory + Path.DirectorySeparatorChar + LogFileName),
                                                          preferredLoggingLevel, LoggingMode.Minimum);
                LogTestHeader();

                SetupEnforcement before = null;

                try
                {
                    IndicateSetup();
                    before = new SetupEnforcement(this);
                    try
                    {
                        setupResult = Setup();
                    }
                    finally
                    {
                        WasSetup = true;
                    }
                }
                catch (Exception thisFailure)
                {
                    setupResult = false;
                    AddResult(GetResultForPreclusionInSetup(thisFailure));
                }
                finally
                {
                    if (!new SetupEnforcement(this).matches(before))
                    {
                        setupResult = false;
                        AddResult(new TestResult(TestStatus.Inconclusive, "PROGRAMMING ERROR: It is illegal to change the identifier, name, or priority in Setup.  This must happen in the constructor."));
                    }
                    IndicateSectionEnd();
                }

                if (setupResult && (CoarseGrind.KILL_SWITCH == false))
                {
                    try
                    {
                        IndicateBody();
                        Console.Error.Write("Running " + this.IdentifiedName);
                        executionThread = new Thread(PerformTest);
                        executionThread.Start();
                        executionThread.Join();
                    }
                    catch (Exception thisFailure)
                    {
                        AddResult(GetResultForFailure(thisFailure));
                    }
                    finally
                    {
                        WasRun          = true;
                        executionThread = null;
                        IndicateSectionEnd();
                    }
                }
                else
                {
                    AddResult(new TestResult(TestStatus.Inconclusive,
                                             "Declining to perform test case " + IdentifiedName
                                             + " because setup method failed."));
                }

                try
                {
                    IndicateCleanup();
                    Console.Error.WriteLine(" - " + OverallStatus);
                    Cleanup();
                    WasCleanedUp = true;
                }
                catch (Exception thisFailure)
                {
                    ReportFailureInCleanup(thisFailure);
                }
                finally
                {
                    IndicateSectionEnd();
                }

                TestStatus overall = OverallStatus;
                Log.Message("<h1>Overall Status: " + overall.ToString() + "</h1>", overall.ToLoggingLevel(), overall.ToHtmlLogIcon());
                Log.ClearSpecificOutput(thisOutputIdentifier);
            }
        }
Example #14
0
 /// ---------------------------------------------------------------------------
 /// <summary></summary>
 /// ---------------------------------------------------------------------------
 static public string ParseType(TestStatus value)
 {
     return ParseType(value.GetType().ToString(), value.ToString());
 }
Example #15
0
 public Result(ResultAdapter result, TestStatus status = TestStatus.None)
 {
     Status       = status == TestStatus.None ? result.Outcome.Status.ToString() : status.ToString();
     StackTrace   = result.StackTrace;
     ErrorMessage = result.Message;
 }
Example #16
0
 public static TestTag Previously(TestStatus status)
 {
     return(new TestTag(TestTagType.Previously, status.ToString()));
 }
 /// <summary>
 /// Allows for test cases to continue running when an error, which is not related to the objective of the test case, occurs but impacts the overall result of the test case.
 /// Used in conjection with CheckForTestStatusInjection method, which is part of the TearDown attribute in the BaseClass.
 /// </summary>
 /// <param name="status"></param>
 /// <param name="logMsg"></param>
 public static void InjectTestStatus(TestStatus status, string logMsg)
 {
     BaseUtil.CreateVar($"_msgKey", logMsg);
     BaseUtil.CreateVar($"_statusKey", status.ToString());
 }
        private string FormatCountWithCategories(TestStatus status)
        {
            var output = new StringBuilder();
            output.Append(CountPerStatus(status) + " " + status.ToString().ToLower());
            var categories = CountPerCategory(status);
            
            if (categories.Count > 0)
            {
                output.Append(" (");
                bool first = true;

                foreach (var pair in categories)
                {
                    if (!first)
                        output.Append(", ");

                    output.Append(pair.Value + " " + pair.Key);
                    first = false;
                }

                output.Append(")");
            }

            return output.ToString();
        }
 public override Task <IGraphQLResponse> UpdateTestRunStatusById(string testRunId, TestStatus testStatus)
 {
     return(SendXrayGraphQLQuery <UpdateTestRunStatusByIdResponse>(str => str.Replace("[VAR1]", testRunId).Replace("[VAR2]", testStatus.ToString())));
 }
Example #20
0
 private static void WriteStatus(this Utf8JsonWriter jsonTextWriter, TestStatus status) =>
 jsonTextWriter.WriteString("status", status.ToString().ToLower());
Example #21
0
        public override string ToString()
        {
            string text = status.ToString();

            return((label == null || label.Length == 0) ? text : $"{text}:{label}");
        }
Example #22
0
        private void UpdateTestResultSummary(TestStatus testStatus)
        {
            string matchingStatusCountString = _testResults.Count(v => v.Value.CurrentStatus == testStatus).ToString();

            switch (testStatus)
            {
            case TestStatus.AwaitingRun:
                lbl_PendingNumber.Text = matchingStatusCountString;
                break;

            case TestStatus.CompleteButUnknown:
            case TestStatus.Running:
            case TestStatus.Unknown:
            case TestStatus.Inconclusive:
                lbl_InconclusiveNumber.Text = matchingStatusCountString;
                break;

            case TestStatus.Failed:
            case TestStatus.FailedWithException:
            case TestStatus.Timeout:
                lbl_FailedNumber.Text = matchingStatusCountString;
                break;

            case TestStatus.Passed:
                lbl_PassedNumber.Text = matchingStatusCountString;
                break;

            case TestStatus.Skipped:
                lbl_SkippedNumber.Text = matchingStatusCountString;
                break;

            default:
                throw new ArgumentException("Cannot figure out which number to increment for a test to that is " + testStatus.ToString());
            }
        }