Esempio n. 1
0
        public void RecordRunResult()
        {
            TestSetCommand tsCommand = new TestSetCommand(EntityCommand.verb.createtestset, ServerUrl, AdminUser, AdminPassword, AlmDomain, StandardProject);

            tsCommand.AddDestinationPath("Root\\UnitTests");
            tsCommand.AddTestSetName(DateTime.Now.ToString() + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name);

            XDocument xml       = XDocument.Parse(ExecuteCmd(tsCommand.CommandString)[0]);
            int       TestSetId = int.Parse(GetElementValue(xml, "entityid"));

            tsCommand = new TestSetCommand(EntityCommand.verb.addtesttotestset, ServerUrl, AdminUser, AdminPassword, AlmDomain, StandardProject);
            tsCommand.AddTestSetId(TestSetId);
            tsCommand.AddTestConfigId(1002);

            xml = XDocument.Parse(ExecuteCmd(tsCommand.CommandString)[0]);

            TestRunCommand trCommand = new TestRunCommand(EntityCommand.verb.recordrunresult, ServerUrl, AdminUser, AdminPassword, AlmDomain, StandardProject);

            trCommand.AddTestSetId(TestSetId);
            trCommand.AddRunName("My Test");
            trCommand.AddTestConfigId(1002);
            trCommand.AddTestStatus(ALMReportingBridge.ALMEntity.TestStatus.Passed);

            xml = XDocument.Parse(ExecuteCmd(trCommand.CommandString)[0]);

            Assert.AreEqual("RecordRunResult", GetElementValue(xml, "operation"));
            Assert.AreEqual("Success", GetElementValue(xml, "status"));
            Assert.AreNotEqual(0, GetElementValue(xml, "entityid"));
        }
        void WhenSendingTestRunAsJson(string testWorkflowName, TestRunStatuses status)
        {
            var testRunCommand = new TestRunCommand {
                WorkflowName = testWorkflowName, Status = status
            };

            WhenSendingTestRunAsJson(testWorkflowName, UrlList.TestRunsControlPoint_absPath, testRunCommand);
        }
        void GivenTestRunPending(string testWorkflowName)
        {
            var testRunCommand = new TestRunCommand {
                WorkflowName = testWorkflowName, Status = TestRunStatuses.Running
            };                                                                                                             // will be pending

            WhenSendingTestRunAsJson(testWorkflowName, UrlList.TestRunsControlPoint_absPath, testRunCommand);
        }
 public bool SetTestRunDataAndCreateTestRun(ITestRunCommand testRunCommand, DynamicDictionary formData)
 {
     if (null == testRunCommand)
         testRunCommand = new TestRunCommand { TestRunName = formData["test_run_name"] ?? string.Empty, WorkflowName = formData["workflow_name"] ?? string.Empty };
     if (string.IsNullOrEmpty(testRunCommand.WorkflowName))
         testRunCommand.WorkflowName = formData["workflow_name"] ?? string.Empty;
     if (string.IsNullOrEmpty(testRunCommand.TestRunName))
         testRunCommand.TestRunName = formData["test_run_name"] ?? string.Empty;
     
     return PrepareTestRun(testRunCommand, formData);
 }
        public virtual bool SetTestRunDataAndCreateTestRun(ITestRunCommand testRunCommand, DynamicDictionary formData)
        {
            CurrentTestRunId = Guid.Empty;
            if (null == testRunCommand)
                testRunCommand = new TestRunCommand { TestRunName = formData[Tmx_Core_Resources.TestRunCommand_testRunName_param] ?? string.Empty, WorkflowName = formData[Tmx_Core_Resources.TestRunCommand_workflowName_param] ?? string.Empty };
            if (string.IsNullOrEmpty(testRunCommand.WorkflowName))
                testRunCommand.WorkflowName = formData[Tmx_Core_Resources.TestRunCommand_workflowName_param] ?? string.Empty;
            if (string.IsNullOrEmpty(testRunCommand.TestRunName))
                testRunCommand.TestRunName = formData[Tmx_Core_Resources.TestRunCommand_testRunName_param] ?? string.Empty;

            return PrepareTestRun(testRunCommand, formData);
        }
Esempio n. 6
0
        public virtual bool SetTestRunDataAndCreateTestRun(ITestRunCommand testRunCommand, DynamicDictionary formData)
        {
            CurrentTestRunId = Guid.Empty;
            if (null == testRunCommand)
            {
                testRunCommand = new TestRunCommand {
                    TestRunName = formData[Resources.TestRunCommand_testRunName_param] ?? string.Empty, WorkflowName = formData[Resources.TestRunCommand_workflowName_param] ?? string.Empty
                }
            }
            ;
            if (string.IsNullOrEmpty(testRunCommand.WorkflowName))
            {
                testRunCommand.WorkflowName = formData[Resources.TestRunCommand_workflowName_param] ?? string.Empty;
            }
            if (string.IsNullOrEmpty(testRunCommand.TestRunName))
            {
                testRunCommand.TestRunName = formData[Resources.TestRunCommand_testRunName_param] ?? string.Empty;
            }

            return(PrepareTestRun(testRunCommand, formData));
        }

        bool PrepareTestRun(ITestRunCommand testRunCommand, DynamicDictionary formData)
        {
            var testRunInitializer = ServerObjectFactory.Resolve <TestRunInitializer>();
            var testRun            = testRunInitializer.CreateTestRun(testRunCommand, formData);

            CurrentTestRunId = testRun.Id;

            if (Guid.Empty == testRun.WorkflowId) // ??
            {
                return(false);
            }
            TestRunQueue.TestRuns.Add(testRun);

            foreach (var testRunAction in testRun.BeforeActions)
            {
                testRunAction.Run();
            }
            return(true);
        }
Esempio n. 7
0
 public bool CreateTestRun(string workflowName, TestRunStatuses status, string name)
 {
     Trace.TraceInformation("CreateTestRun(string workflowName, TestRunStatuses status, string name).1");
     
     var testRunCommand = new TestRunCommand {
         TestRunName = name,
         Status = status,
         WorkflowName = workflowName
     };
     
     Trace.TraceInformation("CreateTestRun(string workflowName, TestRunStatuses status, string name).2");
     
     var creatingTestRunResponse = _restTemplate.PostForMessage(UrlList.TestRunsControlPoint_absPath, testRunCommand);
     
     Trace.TraceInformation("CreateTestRun(string workflowName, TestRunStatuses status, string name).3 creatingTestRunResponse is null? {0}", null == creatingTestRunResponse);
     // 20150316
     if (null == creatingTestRunResponse)
         throw  new Exception("Failed to create a test run.");
     
     return HttpStatusCode.Created == creatingTestRunResponse.StatusCode;
 }
Esempio n. 8
0
        public void AttachToRun()
        {
            TestSetCommand tsCommand = new TestSetCommand(EntityCommand.verb.createtestset, ServerUrl, AdminUser, AdminPassword, AlmDomain, StandardProject);

            tsCommand.AddDestinationPath("Root\\UnitTests");
            tsCommand.AddTestSetName(DateTime.Now.ToString() + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name);

            XDocument xml       = XDocument.Parse(ExecuteCmd(tsCommand.CommandString)[0]);
            int       TestSetId = int.Parse(GetElementValue(xml, "entityid"));

            tsCommand = new TestSetCommand(EntityCommand.verb.addtesttotestset, ServerUrl, AdminUser, AdminPassword, AlmDomain, StandardProject);
            tsCommand.AddTestSetId(TestSetId);
            tsCommand.AddTestConfigId(1002);

            xml = XDocument.Parse(ExecuteCmd(tsCommand.CommandString)[0]);

            TestRunCommand trCommand = new TestRunCommand(EntityCommand.verb.recordrunresult, ServerUrl, AdminUser, AdminPassword, AlmDomain, StandardProject);

            trCommand.AddTestSetId(TestSetId);
            trCommand.AddRunName("My Test");
            trCommand.AddTestConfigId(1002);
            trCommand.AddTestStatus(ALMReportingBridge.ALMEntity.TestStatus.Passed);

            xml = XDocument.Parse(ExecuteCmd(trCommand.CommandString)[0]);

            int RunId = int.Parse(GetElementValue(xml, "entityid"));

            trCommand = new TestRunCommand(EntityCommand.verb.attachtorun, ServerUrl, AdminUser, AdminPassword, AlmDomain, StandardProject);
            trCommand.AddRunId(RunId);
            trCommand.AddAttachmentPath(AttachmentPath);
            trCommand.AddAttachmentType(ALMReportingBridge.ALMEntity.AttachmentType.File);
            trCommand.AddAttachmentName("My super awesome attachment.txt");
            trCommand.AddAttachmentDescription("this is a description for an attachment");

            xml = XDocument.Parse(ExecuteCmd(trCommand.CommandString)[0]);
            Assert.AreEqual("AttachToRun", GetElementValue(xml, "operation"));
            Assert.AreEqual("Success", GetElementValue(xml, "status"));
        }
Esempio n. 9
0
        public virtual bool CreateTestRun(string workflowName, TestRunStatuses status, string name)
        {
            Trace.TraceInformation("CreateTestRun(string workflowName, TestRunStatuses status, string name).1");

            var testRunCommand = new TestRunCommand {
                TestRunName  = name,
                Status       = status,
                WorkflowName = workflowName
            };

            Trace.TraceInformation("CreateTestRun(string workflowName, TestRunStatuses status, string name).2");

            var creatingTestRunResponse = _restTemplate.PostForMessage(UrlList.TestRunsControlPoint_absPath, testRunCommand);

            Trace.TraceInformation("CreateTestRun(string workflowName, TestRunStatuses status, string name).3 creatingTestRunResponse is null? {0}", null == creatingTestRunResponse);

            if (null == creatingTestRunResponse)
            {
                throw  new Exception("Failed to create a test run.");
            }

            return(HttpStatusCode.Created == creatingTestRunResponse.StatusCode);
        }
Esempio n. 10
0
        TestRunCommand WHEN_sending_testRun_as_json(string testWorkflowName, TestRunStatuses status)
        {
//            var testRun = new TestRun();
//            var testRunCommand = new TestRunCommand { WorkflowName = testWorkflowName, Status = status };
//            (testRun as TestRun).SetWorkflow(WorkflowCollection.Workflows.First(wfl => wfl.Name == testWorkflowName));
//            _response = _browser.Post(UrlList.TestRunsControlPoint_absPath, with => {
//                with.JsonBody(testRunCommand);
//                with.Accept("application/json");
//            });
//            return _response.Body.DeserializeJson<TestRunCommand>();
            
            var testRunCommand = new TestRunCommand { WorkflowName = testWorkflowName, Status = status };
            return WHEN_sending_testRun_as_json(testWorkflowName, status, UrlList.TestRunsControlPoint_absPath, testRunCommand);
        }
Esempio n. 11
0
 void WhenSendingTestRunAsJson(string testWorkflowName, TestRunStatuses status)
 {
     var testRunCommand = new TestRunCommand { WorkflowName = testWorkflowName, Status = status };
     WhenSendingTestRunAsJson(testWorkflowName, UrlList.TestRunsControlPoint_absPath, testRunCommand);
 }
Esempio n. 12
0
 void GivenTestRunPending(string testWorkflowName)
 {
     var testRunCommand = new TestRunCommand { WorkflowName = testWorkflowName, Status = TestRunStatuses.Running }; // will be pending
     WhenSendingTestRunAsJson(testWorkflowName, UrlList.TestRunsControlPoint_absPath, testRunCommand);
 }