private static void DoSetOutcomeByRun(RhinoTestCase testCase, string outcome)
        {
            // setup
            var executor = new JiraCommandsExecutor(testCase.GetAuthentication());

            // send
            var response = RavenCommandsRepository.GetTestStauses().Send(executor).AsJToken();

            // extract status
            var status = response.FirstOrDefault(i => $"{i.SelectToken("name")}".Equals(outcome, Compare));

            // exit conditions
            if (status == default)
            {
                return;
            }

            // exit conditions
            if (!int.TryParse($"{status["id"]}", out int outcomeOut))
            {
                return;
            }

            // send
            RavenCommandsRepository.SetTestExecuteResult(testCase.TestRunKey, testCase.Key, outcomeOut).Send(executor);
        }
コード例 #2
0
        /// <summary>
        /// Set XRay runtime ids on all steps under this RhinoTestCase.
        /// </summary>
        /// <param name="testCase">RhinoTestCase on which to update runtime ids.</param>
        /// <param name="testExecutionKey">Jira test execution key by which to find runtime ids.</param>
        public static void SetRuntimeKeys(this RhinoTestCase testCase, string testExecutionKey)
        {
            // setup
            var ravenClient = new JiraCommandsExecutor(testCase.GetAuthentication());
            var command     = RavenCommandsRepository.GetTestRunExecutionDetails(testExecutionKey, testCase.Key);

            // send
            var response = ravenClient.SendCommand(command).AsJToken();

            // exit conditions
            if ($"{response["id"]}".Equals("-1"))
            {
                return;
            }

            // setup
            var jsonToken  = response["steps"];
            var stepsToken = JArray.Parse($"{jsonToken}");
            var stepsCount = testCase.Steps.Count();

            // apply runtime id to test-step context
            for (int i = 0; i < stepsCount; i++)
            {
                testCase.Steps.ElementAt(i).Context["runtimeid"] = stepsToken[i]["id"].ToObject <long>();
                testCase.Steps.ElementAt(i).Context["testStep"]  = JToken.Parse($"{stepsToken[i]}");
            }

            // apply test run key
            int.TryParse($"{response["id"]}", out int idOut);
            testCase.Context["runtimeid"]  = idOut;
            testCase.Context["testRunKey"] = testExecutionKey;
        }
コード例 #3
0
        /// <summary>
        /// Set XRay test execution results of test case by setting steps outcome.
        /// </summary>
        /// <param name="testCase">RhinoTestCase by which to update XRay results.</param>
        /// <returns>-1 if failed to update, 0 for success.</returns>
        /// <remarks>Must contain runtimeid field in the context.</remarks>
        public static void SetOutcomeBySteps(this RhinoTestCase testCase)
        {
            // get steps
            // add exceptions images - if exists or relevant
            if (testCase.Context.ContainsKey(ContextEntry.OrbitResponse))
            {
                testCase.AddExceptionsScreenshot();
            }

            // collect steps
            var steps = new List <object>();

            foreach (var testStep in testCase.Steps)
            {
                steps.Add(testStep.GetUpdateRequest(outcome: $"{testCase.Context["outcome"]}"));
            }

            // setup
            var executor = new JiraCommandsExecutor(testCase.GetAuthentication());
            var command  = RavenCommandsRepository.UpdateTestRun(
                testRun: $"{testCase.Context["runtimeid"]}",
                data: new { Steps = steps });

            // send
            executor.SendCommand(command);
        }
コード例 #4
0
        /// <summary>
        /// Gets all tests under this RhinoTestRun execution.
        /// </summary>
        /// <param name="testRun">RhinoTestRun by which to get tests.</param>
        public static JToken GetTests(this RhinoTestRun testRun)
        {
            // setup
            var executor = new JiraCommandsExecutor(testRun.GetAuthentication());

            // get results
            var response = RavenCommandsRepository.GetTestsByExecution(testRun.Key).Send(executor).AsJToken();

            // return all tests
            return(response is JArray ? response : JToken.Parse("[]"));
        }
        /// <summary>
        /// Updates test results comment.
        /// </summary>
        /// <param name="testCase">RhinoTestCase by which to update test results.</param>
        public static void UpdateResultComment(this RhinoTestCase testCase, string comment)
        {
            // setup
            var executor = new JiraCommandsExecutor(testCase.GetAuthentication());
            var command  = RavenCommandsRepository.UpdateTestRun(
                testRun: $"{testCase.Context["runtimeid"]}",
                data: new { Comment = comment });

            // send
            executor.SendCommand(command);
        }
コード例 #6
0
 /// <summary>
 /// Creates a new instance of JiraClient.
 /// </summary>
 /// <param name="authentication">Authentication information by which to connect and fetch data from Jira.</param>
 /// <param name="logger">Logger implementation for this client.</param>
 public XpandClient(JiraAuthentication authentication, ILogger logger)
 {
     // setup
     this.logger    = logger?.CreateChildLogger(loggerName : nameof(XpandClient));
     jiraClient     = new JiraClient(authentication, this.logger);
     Authentication = jiraClient.Authentication;
     executor       = new JiraCommandsExecutor(authentication, this.logger);
     bucketSize     = authentication.GetCapability(ProviderCapability.BucketSize, 4);
     options        = new ParallelOptions {
         MaxDegreeOfParallelism = bucketSize
     };
 }
        /// <summary>
        /// Set XRay runtime ids on all steps under this RhinoTestCase.
        /// </summary>
        /// <param name="testCase">RhinoTestCase on which to update runtime ids.</param>
        /// <param name="testExecutionKey">Jira test execution key by which to find runtime ids.</param>
        public static void SetRuntimeKeys(this RhinoTestCase testCase, string testExecutionKey)
        {
            // setup
            var ravenClient = new JiraCommandsExecutor(testCase.GetAuthentication());
            var command     = RavenCommandsRepository.GetTestRunExecutionDetails(testExecutionKey, testCase.Key);

            // send
            var response = ravenClient.SendCommand(command).AsJToken();

            // exit conditions
            if ($"{response["id"]}".Equals("-1"))
            {
                return;
            }

            // setup
            var jsonToken  = response["steps"];
            var stepsToken = JArray.Parse($"{jsonToken}");
            var aggregated = testCase.AggregateSteps();
            var steps      = aggregated.Steps.ToList();

            // apply runtime id to test-step context
            for (int i = 0; i < steps.Count; i++)
            {
                steps[i].Context["runtimeid"] = stepsToken[i]["id"].ToObject <long>();
                steps[i].Context["testStep"]  = JToken.Parse($"{stepsToken[i]}");

                var isKey  = steps[i].Context.ContainsKey(ContextEntry.ChildSteps);
                var isType = isKey && steps[i].Context[ContextEntry.ChildSteps] is IEnumerable <RhinoTestStep>;
                if (isType)
                {
                    foreach (var _step in (IEnumerable <RhinoTestStep>)steps[i].Context[ContextEntry.ChildSteps])
                    {
                        _step.Context["runtimeid"] = steps[i].Context["runtimeid"];
                    }
                }
            }

            // apply test run key
            _ = int.TryParse($"{response["id"]}", out int idOut);
            testCase.Context["runtimeid"]  = idOut;
            testCase.Context["testRunKey"] = testExecutionKey;
            testCase.Context["aggregated"] = aggregated;
            aggregated.Steps = steps;
        }
        /// <summary>
        /// Upload evidences into an existing test execution.
        /// </summary>
        /// <param name="testCase">RhinoTestCase by and into which to upload evidences.</param>
        public static void UploadEvidences(this RhinoTestCase testCase)
        {
            // setup
            var runOut = 0;

            if (testCase.Context.ContainsKey("runtimeid"))
            {
                _ = int.TryParse($"{testCase.Context["runtimeid"]}", out runOut);
            }

            // build
            var executor = new JiraCommandsExecutor(testCase.GetAuthentication());

            // send
            foreach (var(Id, Data) in GetEvidence(testCase))
            {
                RavenCommandsRepository.CreateAttachment($"{runOut}", $"{Id}", Data).Send(executor);
            }
        }
コード例 #9
0
        /// <summary>
        /// Creates a new instance of this Rhino.Api.Simulator.Framework.XrayAutomationProvider.
        /// </summary>
        /// <param name="configuration">Rhino.Api.Contracts.Configuration.RhinoConfiguration to use with this provider.</param>
        /// <param name="types">A collection of <see cref="Type"/> to load for this repository.</param>
        /// <param name="logger">Gravity.Abstraction.Logging.ILogger implementation for this provider.</param>
        public XrayAutomationProvider(RhinoConfiguration configuration, IEnumerable <Type> types, ILogger logger)
            : base(configuration, types, logger)
        {
            // setup
            this.logger = logger?.Setup(loggerName: nameof(XrayAutomationProvider));

            var authentication = configuration.GetJiraAuthentication();

            jiraClient   = new JiraClient(authentication);
            jiraExecutor = new JiraCommandsExecutor(authentication);

            // capabilities
            BucketSize = configuration.GetBucketSize();
            configuration.PutDefaultCapabilities();
            capabilities = configuration.Capabilities.ContainsKey($"{Connector.JiraXRay}:options")
                ? configuration.Capabilities[$"{Connector.JiraXRay}:options"] as IDictionary <string, object>
                : new Dictionary <string, object>();

            // integration
            bugsManager = new JiraBugsManager(jiraClient);
        }
コード例 #10
0
        /// <summary>
        /// Creates a new instance of this Rhino.Api.Simulator.Framework.XrayAutomationProvider.
        /// </summary>
        /// <param name="configuration">Rhino.Api.Contracts.Configuration.RhinoConfiguration to use with this provider.</param>
        /// <param name="types">A collection of <see cref="Type"/> to load for this repository.</param>
        /// <param name="logger">Gravity.Abstraction.Logging.ILogger implementation for this provider.</param>
        public XrayCloudAutomationProvider(RhinoConfiguration configuration, IEnumerable <Type> types, ILogger logger)
            : base(configuration, types, logger)
        {
            // setup
            this.logger = logger?.Setup(loggerName: nameof(XrayCloudAutomationProvider));
            jiraClient  = new JiraClient(configuration.GetJiraAuthentication());
            xpandClient = new XpandClient(configuration.GetJiraAuthentication());
            executor    = new JiraCommandsExecutor(configuration.GetJiraAuthentication());

            // capabilities
            BucketSize = configuration.GetBucketSize();
            configuration.PutDefaultCapabilities();
            capabilities = configuration.Capabilities.ContainsKey($"{Connector.JiraXryCloud}:options")
                ? configuration.Capabilities[$"{Connector.JiraXryCloud}:options"] as IDictionary <string, object>
                : new Dictionary <string, object>();

            // misc
            options = new ParallelOptions {
                MaxDegreeOfParallelism = BucketSize
            };

            // integration
            bugsManager = new JiraBugsManager(jiraClient);
        }
コード例 #11
0
        /// <summary>
        /// Set XRay test execution results of test case by setting steps outcome.
        /// </summary>
        /// <param name="testCase">RhinoTestCase by which to update XRay results.</param>
        /// <returns>-1 if failed to update, 0 for success.</returns>
        /// <remarks>Must contain runtimeid field in the context.</remarks>
        public static void SetOutcomeBySteps(this RhinoTestCase testCase)
        {
            // get steps
            var onTestCase = testCase.AggregateSteps();

            onTestCase.Context.AddRange(testCase.Context, new[] { "aggregated" });

            // collect steps
            var steps = new List <object>();

            foreach (var testStep in onTestCase.Steps)
            {
                steps.Add(testStep.GetUpdateRequest(outcome: $"{onTestCase.Context["outcome"]}"));
            }

            // setup
            var executor = new JiraCommandsExecutor(onTestCase.GetAuthentication());
            var command  = RavenCommandsRepository.UpdateTestRun(
                testRun: $"{onTestCase.Context["runtimeid"]}",
                data: new { Steps = steps });

            // send
            executor.SendCommand(command);
        }
 /// <summary>
 /// Sends an Http command and return the result as JToken instance.
 /// </summary>
 /// <param name="command">The command to send.</param>
 /// <param name="executor">The JiraCommandsExecutor to use for sending the command.</param>
 /// <returns>JToken with the request results.</returns>
 public static string Send(this HttpCommand command, JiraCommandsExecutor executor)
 {
     return(DoSend(command, executor, authentication: default));
 }