Example #1
0
        public async Task TestWorkItemTest()
        {
            TestStep testStepObject = new TestStep();

            testStepObject.StepRepro = new List <string> {
                "1st step", "2nd step", "3rd step"
            };
            testStepObject.StepExpected = new List <string> {
                "expect 1st", "expect 2nd", "expect 3rd"
            };
            var steps    = SyncTestCase.SyncTestCase.EncodeHtmlString(testStepObject);
            var testCase = new SyncTestCase.Models.TestCase[]
            {
                new TestCase {
                    Value = "Test Case 1", Operation = "add", Path = "/fields/System.Title"
                },
                new TestCase {
                    Value = steps, Operation = "add", Path = "/fields/Microsoft.VSTS.TCM.Steps"
                },
            };

            var json = JsonConvert.SerializeObject(testCase);

            var 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);
        }
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);
        }