Example #1
0
        /// <summary>
        /// Post the provided GUI Test to the QViz Instance
        /// </summary>
        /// <param name="guiTest">GUI Test as JSON Object</param>
        public void PostGUITest(TestCaseGUI guiTest)
        {
            var apiClient = new APIClient(_baseURL);

            apiClient.Headers.Add(new KeyValue("Content-Type", "application/json"));
            apiClient.Headers.Add(new KeyValue("Authorization", "Bearer " + _user.access_token));
            apiClient.Headers.Add(new KeyValue("userId", _user.userId));
            apiClient.Body = guiTest;
            apiClient.Post <object>("/api/uiTestcases");
            _lastResponse = apiClient.Response.Content;
            if (!apiClient.Response.IsSuccessful)
            {
                throw apiClient.GetError();
            }
        }
Example #2
0
        public void PostGUITestcase()
        {
            try
            {
                _qvizClient.Authenticate(QVizUser, QVizPassword);
                var project = _qvizClient.GetProject(QVizProject);

                var testTags = new List <Tag>
                {
                    new Tag {
                        tagId = null, tagName = "TestTag1"
                    },
                    new Tag {
                        tagId = null, tagName = "TestTag2"
                    }
                };

                /// Test Actions
                Action testAction1 = new Action
                {
                    actionId   = null,
                    fieldName  = "username_test",
                    fieldValue = "demouser",
                    actionType = "Enter",
                };

                List <Action> listTestAction = new List <Action> {
                    testAction1
                };

                //Step Actions
                Action stepAction1 = new Action
                {
                    actionId   = null,
                    fieldName  = "username",
                    fieldValue = "demouser",
                    actionType = "Enter",
                };

                List <Action> stepActions1 = new List <Action> {
                    stepAction1
                };


                List <TestCaseStep> steps = new List <TestCaseStep> {
                    new TestCaseStep {
                        srNo = 1, stepDescription = "Step1", expectedResult = "Step Result1", testCaseStepId = null, stepActions = stepActions1
                    },
                };

                TestSuite tsuite = new TestSuite
                {
                    testsuiteId   = null,
                    testsuiteName = "Smoke Suite"
                };

                List <TestSuite> suites = new List <TestSuite>
                {
                    tsuite
                };

                string typeId = testcaseTypes.FirstOrDefault(f => f.name.ToLower() == "ui").testCaseTypeId;
                // Test case
                TestCaseGUI guiTC = new TestCaseGUI
                {
                    testCaseId      = null,
                    projectId       = project.projectId,
                    moduleId        = modules.FirstOrDefault().moduleId,
                    subModuleId     = subModules.FirstOrDefault().subModuleId,
                    description     = "Demo GUI Test case " + DateTime.Now.Ticks,
                    isAutomated     = false,
                    priority        = "P1",
                    severity        = "1",
                    expectedResult  = "Demo expected result",
                    testCaseTypeId  = typeId,
                    testToolID      = "DemoTool1",
                    testTags        = testTags,
                    testCaseSteps   = steps,
                    testCaseActions = listTestAction,
                    testSuites      = suites,
                };
                _qvizClient.PostGUITest(guiTC);

                string response = _qvizClient.LastResponse();
                QVizResponseObject <TestCaseGUI> qVizResponse = JsonConvert.DeserializeObject <QVizResponseObject <TestCaseGUI> >(response);

                Assert.AreEqual("Test case created successfully", qVizResponse.Message);
            }
            catch (Exception error)
            {
                Assert.Fail(error.Message);
            }
        }