예제 #1
0
 private static void ExpectedResultValidation(TestPlan testPlan)
 {
     //search for problems in expectedResults list
     foreach (var testCase in testPlan.TestCases)
     {
         if (testCase.TestSteps.Count > 1)
         {
             foreach (var testStep in testCase.TestSteps)
             {
                 if (testStep.ExpectedResult == "")
                 {
                     DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("Error. \nTest Case: " + testCase.Title + "\nIndex:[" + testStep.Index + "] don't have expected result. Are you sure you want to continue executing a parsing method?", "Error", MessageBoxButtons.YesNo);
                     if (dialogResult == DialogResult.No)
                     {
                         throw new InvalidExpectedResult();
                     }
                 }
             }
         }
     }
 }
예제 #2
0
        public static TestPlan PopulateTP(UmlUseCaseDiagram UseCaseDiagram, Dictionary <String, UmlActionStateDiagram> dicActionDiagram)
        {
            int index = 2;

            TestPlan testPlan = new TestPlan();

            foreach (String keyUC in UseCaseDiagram.useCases.Keys)
            {
                UmlUseCase useCase = UseCaseDiagram.useCases[keyUC];

                if (useCase.includeList.Count == 0)
                {
                    TestCase testCase = new TestCase(HttpUtility.UrlDecode(useCase.Name));

                    testCase.Title     += "_" + TestCase.contWorkItemId;
                    testCase.WorkItemId = TestCase.contWorkItemId;
                    TestCase.contWorkItemId++;

                    TestStep testStep = new TestStep();

                    testStep.FTstate         = HttpUtility.UrlDecode(useCase.FTstate);
                    testStep.FTassigned      = HttpUtility.UrlDecode(useCase.FTassigned);
                    testStep.FTreason        = HttpUtility.UrlDecode(useCase.FTreason);
                    testStep.FTiterationPath = HttpUtility.UrlDecode(useCase.FTiterationPath);
                    testStep.FTareaPath      = HttpUtility.UrlDecode(useCase.FTareaPath);
                    testStep.FTapplication   = HttpUtility.UrlDecode(useCase.FTapplication);
                    testStep.FTcomplexity    = HttpUtility.UrlDecode(useCase.FTcomplexity);
                    testStep.FTrisks         = HttpUtility.UrlDecode(useCase.FTrisks);
                    testStep.FTtcLifecycle   = HttpUtility.UrlDecode(useCase.FTtcLifecycle);
                    testStep.FTlifecycleType = HttpUtility.UrlDecode(useCase.FTlifecycleType);
                    testStep.FTtcTeamUsage   = HttpUtility.UrlDecode(useCase.FTtcTeamUsage);

                    testStep.Title            = useCase.Name;
                    testStep.workItemIdString = "Test Case " + testCase.WorkItemId;
                    testStep.Index           += index;
                    testStep.Description      = "";
                    testStep.ExpectedResult   = HttpUtility.UrlDecode(useCase.posCondition);

                    foreach (String tagKey in useCase.dictionaryTag.Keys)
                    {
                        testStep.Description += useCase.dictionaryTag[tagKey].value;
                    }

                    if (testStep.Description != null)
                    {
                        testStep.Description = HttpUtility.UrlDecode(testStep.Description).Replace("|", Environment.NewLine + "-");
                    }

                    if (testStep.Description.Contains("["))
                    {
                        testStep.Description = testStep.Description.Replace("[", Environment.NewLine + "[-");
                        testStep.Description = testStep.Description.Replace("[", "[/");
                        testStep.Description = testStep.Description.Replace("]", "/]");

                        String[] list = testStep.Description.Split(new char[] { '[', ']' });


                        for (int i = 0; i < list.Count() - 1; i++)
                        {
                            if (list[i].ToArray()[0] == '/')
                            {
                                list[i] = list[i].Replace("/", "");
                                list[i] = list[i].Replace("-", "  -");
                            }
                        }

                        testStep.Description = String.Join("", list);
                    }

                    if (testStep.Description != "")
                    {
                        testStep.Description = "Pre-Requirements" + Environment.NewLine + Environment.NewLine + testStep.Description;
                    }

                    testCase.TestSteps.Add(testStep);

                    foreach (var item in useCase.dicTagHyperLinkUseCase.Keys)
                    {
                        UmlActionStateDiagram actionDiagram = useCase.dicTagHyperLinkUseCase[item];
                        String        idInicio = actionDiagram.InitialActivity.outgoing;
                        UmlTransition t        = actionDiagram.buscaTransition(idInicio, dicActionDiagram);
                        testStep.Title = actionDiagram.Name;
                        int subIndex = 0;
                        populateActionDiagram("", testStep, "", t, actionDiagram, dicActionDiagram, testCase, index, subIndex, false);
                    }
                    if (testCase.TestSteps.Count > 1)
                    {
                        testCase.TestCaseId = TestCase.contTestCaseId++;
                        testPlan.TestCases.Add(testCase);
                    }
                }
            }

            PopulateTestPlan.ExpectedResultValidation(testPlan);

            return(testPlan);
        }