Example #1
0
        public async Task TestCreateTestSuite()
        {
            var testPlan = new SyncTestCase.Models.TestPlan();

            testPlan.Name      = "API Test Plan_TestSuite";
            testPlan.StartDate = new DateTime(2018, 11, 1);
            testPlan.EndDate   = new DateTime(2018, 11, 30);
            var json = JsonConvert.SerializeObject(testPlan);

            var result = await SyncTestCase.SyncTestCase.InvokeRestAPIPost(json, "testplan/plans?api-version=6.0-preview.1");

            TestPlan = JsonConvert.DeserializeObject <TestPlanRootobject>(result);

            RemoveTestCaseID.Add(TestPlan.id);

            var testSuite = new SyncTestCase.Models.TestSuite();

            testSuite.Name            = "API Test Suite";
            testSuite.Parent.ParentID = TestPlan.rootSuite.id;
            json = JsonConvert.SerializeObject(testSuite);

            result = await SyncTestCase.SyncTestCase.InvokeRestAPIPost(json,
                                                                       string.Format($"testplan/Plans/{TestPlan.id}/suites/?api-version=6.0-preview.1"));

            var testResult = JsonConvert.DeserializeObject <TestSuiteResultRootobject>(result);

            if (testResult.id == 0)
            {
                Assert.Fail("Response ID is zero");
            }
        }
Example #2
0
        public async Task TestCreateTestCase()
        {
            var testPlan = new SyncTestCase.Models.TestPlan();

            testPlan.Name      = "API Test Plan Root";
            testPlan.StartDate = new DateTime(2018, 11, 1);
            testPlan.EndDate   = new DateTime(2018, 11, 30);
            var json = JsonConvert.SerializeObject(testPlan);

            var result = await SyncTestCase.SyncTestCase.InvokeRestAPIPost(json, "testplan/plans?api-version=6.0-preview.1");

            TestPlan = JsonConvert.DeserializeObject <TestPlanRootobject>(result);
            RemoveTestCaseID.Add(TestPlan.id);

            var testSuite = new SyncTestCase.Models.TestSuite();

            testSuite.Name            = "API Test Suite";
            testSuite.Parent.ParentID = TestPlan.rootSuite.id;
            json = JsonConvert.SerializeObject(testSuite);

            result = await SyncTestCase.SyncTestCase.InvokeRestAPIPost(json,
                                                                       string.Format($"testplan/Plans/{TestPlan.id}/suites/?api-version=6.0-preview.1"));

            var testSuiteResult = JsonConvert.DeserializeObject <TestSuiteResultRootobject>(result);

            //テストケース作成
            var testCase = new SyncTestCase.Models.TestCase[1]
            {
                new TestCase {
                    Value = "Case 1", Operation = "add"
                },
            };

            json = JsonConvert.SerializeObject(testCase);

            result = await SyncTestCase.SyncTestCase.InvokeRestAPIPost(json,
                                                                       "wit/workitems/$Test%20Case?api-version=6.0-preview.3", "application/json-patch+json");

            TestCase = JsonConvert.DeserializeObject <TestCaseRootobject>(result);

            //関連付け
            result = await SyncTestCase.SyncTestCase.InvokeRestAPIPost(json,
                                                                       string.Format($"test/Plans/{TestPlan.id}/suites/{testSuiteResult.id}/testcases/{TestCase.id}?api-version=6.0-preview.3"));

            // ステップ登録
            var testStep = new SyncTestCase.Models.TestStep();

            testStep.StepRepro = new List <string> {
                "ブラウザ起動", "ログイン", "About表示", "終了"
            };
            // HTMLにする

            json = JsonConvert.SerializeObject(testStep);

            result = await SyncTestCase.SyncTestCase.InvokeRestAPIPatch(json,
                                                                        $"wit/workitems/{TestCase.id}?api-version=6.0-preview.3");

            var updateResult = JsonConvert.DeserializeObject <UpdateTestCaseRootobject>(result);
        }
Example #3
0
        public async Task TestCreateTestPlan()
        {
            var testPlan = new SyncTestCase.Models.TestPlan();

            testPlan.Name      = "API Test Plan";
            testPlan.StartDate = new DateTime(2018, 11, 1);
            testPlan.EndDate   = new DateTime(2018, 11, 30);
            var json = JsonConvert.SerializeObject(testPlan);

            var result = await SyncTestCase.SyncTestCase.InvokeRestAPIPost(json, "testplan/plans?api-version=6.0-preview.1");

            Assert.IsTrue(string.IsNullOrEmpty(result), "response is null");
            TestPlan = JsonConvert.DeserializeObject <TestPlanRootobject>(result);
            Assert.IsTrue(TestPlan.id == 0, "REST API failed");
            RemoveTestCaseID.Add(TestPlan.id);
        }