Beispiel #1
0
        public static void CreateTestStatus(string projectName)
        {
            try
            {
                var    status       = TestContext.CurrentContext.Result.Outcome.Status;
                var    stacktrace   = "" + TestContext.CurrentContext.Result.StackTrace + "";
                var    errorMessage = TestContext.CurrentContext.Result.Message;
                Status logstatus;
                switch (status)
                {
                case TestStatus.Failed:
                    fCount++;
                    emailBody = emailBody + "<tr><td>" + TestContext.CurrentContext.Test.Name + "</td><td>Failed</td><td>" + errorMessage + "</td></tr>";
                    logstatus = Status.Fail;
                    string screenShotPath = WebDriverUtil.Capture(TestContext.CurrentContext.Test.MethodName, projectName);
                    _test.Log(logstatus, "Test ended with " + logstatus + " – " + errorMessage);
                    _test.Log(logstatus, "Snapshot below: " + _test.AddScreenCaptureFromPath(screenShotPath));
                    break;

                case TestStatus.Skipped:
                    sCount++;
                    emailBody = emailBody + "<tr><td>" + TestContext.CurrentContext.Test.Name + "</td><td>Skipped</td><td>" + errorMessage + "</td></tr>";
                    logstatus = Status.Skip;
                    _test.Log(logstatus, "Test ended with " + logstatus + " - " + errorMessage);
                    break;

                default:
                    pCount++;
                    emailBody = emailBody + "<tr><td>" + TestContext.CurrentContext.Test.Name + "</td><td>Passed</td><td>" + errorMessage + "</td></tr>";
                    logstatus = Status.Pass;
                    _test.Log(logstatus, "Test ended with " + logstatus + " " + errorMessage);
                    break;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }