protected void resolveIssue(string JiraIssueKey, string TransitionName)
        {
            try
            {
                var curIssue = JiraReporter.ChangeState(JiraIssueKey, TransitionName, true);

                if (curIssue != null)
                {
                    Report.Info("Jira issue resolved -- IssueKey: " + curIssue.Key + "; IssueID: " + curIssue.Id);
                    Report.LogHtml(ReportLevel.Info, "<a href=\"" + JiraReporter.ServerURL + "browse/" + curIssue.Id + "\">" + curIssue.Id + "</a>");
                }
                else
                {
                    Report.Warn("Could not resolved Jira issue -- IssueKey: " + curIssue.Id);
                }
            }
            catch (Exception e)
            {
                var    inner = e.InnerException;
                string str   = "";
                if (inner != null)
                {
                    var prop = inner.GetType().GetProperty("ErrorResponse");
                    if (prop != null)
                    {
                        str = (string)prop.GetValue(e.InnerException, null);
                    }
                }

                Report.Error(e.Message + " (InnerException: " + e.InnerException + " -- " + str + ")");
            }
        }
        protected void createIssue(ITestContainer tc)
        {
            try
            {
                var createdIssue = JiraReporter.CreateIssue(tc.Name, true);

                Report.Info("Jira issue created -- IssueKey: " + createdIssue.Key + "; IssueID: " + createdIssue.Id);
                Report.LogHtml(ReportLevel.Info, "<a href=\"" + JiraReporter.ServerURL + "browse/" + createdIssue.Id + "\">" + createdIssue.Id + "</a>");
            }
            catch (Exception e)
            {
                var    inner = e.InnerException;
                string str   = "";
                if (inner != null)
                {
                    var prop = inner.GetType().GetProperty("ErrorResponse");
                    if (prop != null)
                    {
                        str = (string)prop.GetValue(e.InnerException, null);
                    }
                }

                Report.Error(e.Message + " (InnerException: " + e.InnerException + " -- " + str + ")");
            }
        }
Exemplo n.º 3
0
        private void initialConnect()
        {
            try
            {
                JiraConfiguration config = JiraConfiguration.Instance;
                config.ServerUrl = _JiraServerURL;
                config.Password  = _JiraPassword;
                config.UserName  = _JiraUserName;

                JiraReporter.ConnectJiraServer();
                //Report.Info(JiraReporter.GetServerTitle() + " -- " + JiraReporter.GetServerVersion());
            }
            catch (Exception e)
            {
                var    inner = e.InnerException;
                string str   = "";
                if (inner != null)
                {
                    var prop = inner.GetType().GetProperty("ErrorResponse");
                    if (prop != null)
                    {
                        str = (string)prop.GetValue(e.InnerException, null);
                    }
                }

                Report.Error(e.Message + " (InnerException: " + e.InnerException + " -- " + str + ")");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Performs the playback of actions in this module.
        /// </summary>
        /// <remarks>You should not call this method directly, instead pass the module
        /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method
        /// that will in turn invoke this method.</remarks>
        public void Run()
        {
            ITestContainer    tc     = checkTestCase();
            JiraConfiguration config = JiraConfiguration.Instance;

            IEnumerable issues = null;

            if ((config.jqlQueryToConnectIssues == null || config.jqlQueryToConnectIssues.Length == 0) &&
                (config.RxAutomationFieldName == null || config.RxAutomationFieldName.Length == 0))
            {
                issues = Enumerable.Empty <Issue>();
            }
            else if (config.jqlQueryToConnectIssues.Length > 0)
            {
                issues = JiraReporter.getJiraIssues(config.jqlQueryToConnectIssues);
            }
            else
            {
                issues = JiraReporter.getJiraIssues("'" + config.RxAutomationFieldName + "' ~ '" + tc.Name + "'");
            }

            if (tc.Status == Ranorex.Core.Reporting.ActivityStatus.Failed)
            {
                bool isEmpty = true;
                foreach (Issue issue in issues)
                {
                    if (!issue.Status.Name.Contains(config.StateReopen))
                    {
                        reopenIssue(issue.Key.ToString(), config.StateReopen);
                    }
                    else
                    {
                        Report.Info("Jira issue is already open -- IssueKey: " + issue.Key.ToString() + "; IssueID: " + issue.Key.ToString());
                        Report.LogHtml(ReportLevel.Info, "<a href=\"" + JiraReporter.ServerURL + "browse/" + issue.Key.ToString() + "\">" + issue.Key.ToString() + "</a>");
                    }
                    isEmpty = false;
                }
                if (isEmpty)
                {
                    createIssue(tc);
                }
            }
            else if (tc.Status == Ranorex.Core.Reporting.ActivityStatus.Success)
            {
                foreach (Issue issue in issues)
                {
                    if (!issue.Status.Name.Contains(config.StateClosed))
                    {
                        resolveIssue(issue.Key.ToString(), config.StateClosed);
                    }
                }
            }
        }
        void ITestModule.Run()
        {
            JiraConfiguration config = JiraConfiguration.Instance;

            if (!config.enabled)
            {
                Report.Debug("Jira integration disabled in config!");
                return;
            }


            var tc = TestSuite.CurrentTestContainer;

            if (tc == null)
            {
                Report.Error("TestCase is 'null'; this usually happens when the module is used outside of testcases (e.g., global teardown).");
            }

            if (tc.Status == Ranorex.Core.Reporting.ActivityStatus.Failed)
            {
                try
                {
                    char          delimiterChar = ';';
                    List <string> labels        = null;

                    if (!string.IsNullOrEmpty(JiraLabels))
                    {
                        labels = new List <string>(JiraLabels.Split(delimiterChar));
                    }

                    var curIssue = JiraReporter.UpdateIssue(JiraIssueKey, tc.Name, JiraSummary, JiraDescription, labels, true);

                    Report.Info("Jira issue updated -- IssueKey: " + curIssue.Key + "; IssueID: " + curIssue.Id);
                    Report.LogHtml(ReportLevel.Info, "<a href=\"" + JiraReporter.ServerURL + "/browse/" + curIssue.Id + "\">" + curIssue.Id + "</a>");
                }
                catch (Exception e)
                {
                    var    inner = e.InnerException;
                    string str   = "";
                    if (inner != null)
                    {
                        var prop = inner.GetType().GetProperty("ErrorResponse");
                        if (prop != null)
                        {
                            str = (string)prop.GetValue(e.InnerException, null);
                        }
                    }

                    Report.Error(e.Message + " (InnerException: " + e.InnerException + " -- " + str + ")");
                }
            }
        }
Exemplo n.º 6
0
 public static string getCurrentSprintName()
 {
     return(JiraReporter.getCurrentSprintItem("name"));
 }
Exemplo n.º 7
0
 public static string getCurrentSprintId()
 {
     return(JiraReporter.getCurrentSprintItem("id"));
 }
Exemplo n.º 8
0
        public void Run()
        {
            JiraConfiguration config = JiraConfiguration.Instance;

            if (!config.enabled)
            {
                Report.Debug("Jira integration disabled in config!");
                return;
            }

            ITestContainer tc = checkTestCase();

            //Try to get issues associated with the test case
            IEnumerable issues = null;

            if ((config.jqlQueryToConnectIssues == null || config.jqlQueryToConnectIssues.Length == 0) &&
                (config.RxAutomationFieldName == null || config.RxAutomationFieldName.Length == 0) &&
                (config.transientConfig.JiraIssueKey == null || config.transientConfig.JiraIssueKey.Length == 0))
            {
                issues = Enumerable.Empty <Issue>();
            }
            else if (config.jqlQueryToConnectIssues.Length > 0)
            {
                issues = JiraReporter.getJiraIssues(config.jqlQueryToConnectIssues);
            }
            else if (config.transientConfig.JiraIssueKey.Length > 0)
            {
                issues = JiraReporter.getJiraIssues("issue=" + config.transientConfig.JiraIssueKey);
            }
            else
            {
                issues = JiraReporter.getJiraIssues("'" + config.RxAutomationFieldName + "' ~ '" + tc.Name + "'");
            }

            // if no issues were found, create one; otherwise reopen existing ones
            if (tc.Status == Ranorex.Core.Reporting.ActivityStatus.Failed)
            {
                bool isEmpty = true;
                foreach (Issue issue in issues)
                {
                    if (!issue.Status.Name.Contains(config.StateReopen))
                    {
                        reopenIssue(issue.Key.ToString(), config.StateReopen);
                    }
                    else
                    {
                        Report.Info("Jira issue is already open -- IssueKey: " + issue.Key.ToString() + "; IssueID: " + issue.Key.ToString());
                        Report.LogHtml(ReportLevel.Info, "<a href=\"" + JiraReporter.ServerURL + "browse/" + issue.Key.ToString() + "\">" + issue.Key.ToString() + "</a>");
                    }
                    isEmpty = false;
                }
                if (isEmpty)
                {
                    createIssue(tc);
                }
            }
            // otherwise, if the test case was successful, close the issues
            else if (tc.Status == Ranorex.Core.Reporting.ActivityStatus.Success)
            {
                foreach (Issue issue in issues)
                {
                    if (!issue.Status.Name.Contains(config.StateClosed))
                    {
                        resolveIssue(issue.Key.ToString(), config.StateClosed);
                    }
                }
            }

            config.transientConfig.Clear();
        }