/// <summary>
        /// Creates a new test case under the specified automation provider.
        /// </summary>
        /// <param name="testCase">Rhino.Api.Contracts.AutomationProvider.RhinoTestCase by which to create automation provider test case.</param>
        /// <returns>The ID of the newly created entity.</returns>
        public override string CreateTestCase(RhinoTestCase testCase)
        {
            // shortcuts
            var onProject = Configuration.ConnectorConfiguration.Project;

            testCase.Context[ContextEntry.Configuration] = Configuration;
            var testType = $"{testCase.GetCapability(AtlassianCapabilities.TestType, "Test")}";

            // setup context
            testCase.Context["issuetype-id"]                   = $"{jiraClient.GetIssueTypeFields(idOrKey: testType, path: "id")}";
            testCase.Context["project-key"]                    = onProject;
            testCase.Context["test-sets-custom-field"]         = jiraClient.GetCustomField(schema: TestSetSchema);
            testCase.Context["manual-test-steps-custom-field"] = jiraClient.GetCustomField(schema: ManualTestStepSchema);
            testCase.Context["test-plan-custom-field"]         = jiraClient.GetCustomField(schema: AssociatedPlanSchema);

            // setup request body
            var requestBody = testCase.ToJiraXrayIssue();
            var issue       = jiraClient.Create(requestBody);

            // comment
            var comment = Utilities.GetActionSignature(action: "created");

            jiraClient.AddComment(idOrKey: $"{issue.SelectToken("key")}", comment);

            // success
            Logger?.InfoFormat($"Create-Test -Project [{onProject}] -Set [{string.Join(",", testCase?.TestSuites)}] = true");

            // results
            return($"{issue}");
        }
        private JToken CreateTestOnJira(RhinoTestCase testCase)
        {
            // shortcuts
            var onProject = Configuration.ConnectorConfiguration.Project;
            var testType  = $"{capabilities[AtlassianCapabilities.TestType]}";

            // setup context
            testCase.Context["issuetype-id"] = $"{jiraClient.GetIssueTypeFields(idOrKey: testType, path: "id")}";
            testCase.Context["project-key"]  = onProject;

            // setup request body
            var issue = jiraClient.Create(testCase.ToJiraCreateRequest()).AsJObject();

            if (issue == default || !issue.ContainsKey("id"))
            {
                logger?.Fatal("Was not able to create a test case.");
                return(default);
Beispiel #3
0
        // UTILITIES
        private static string PriorityToBugMarkdown(RhinoTestCase testCase, JiraClient jiraClient)
        {
            // get priority token
            var priorityData = jiraClient.GetIssueTypeFields("Bug", "fields.priority");

            // exit conditions
            if (string.IsNullOrEmpty(priorityData))
            {
                return(string.Empty);
            }

            // setup
            var id   = Regex.Match(input: testCase.Priority, @"\d+").Value;
            var name = Regex.Match(input: testCase.Priority, @"(?<=\d+\s+-\s+)\w+").Value;

            // extract
            var priority = JToken
                           .Parse(priorityData)["allowedValues"]
                           .FirstOrDefault(i => $"{i["name"]}".Equals(name, Compare) && $"{i["id"]}".Equals(id, Compare));

            // results
            return(priority == null ? testCase.Priority : $"{priority.SelectToken("id")}");
        }