コード例 #1
0
        public override List <GeneralUseStructure> GenerateSequence(List <GeneralUseStructure> listGeneralStructure, ref int tcCount, StructureType type)
        {
            GenerateTestPlanDFSforTCC  populate   = new GenerateTestPlanDFSforTCC();
            List <TestPlanForTCC>      listPlan   = new List <TestPlanForTCC> ();
            List <GeneralUseStructure> listScript = new List <GeneralUseStructure> ();
            List <GeneralUseStructure> listSequenceGenerationStructure = base.ConvertStructure(listGeneralStructure, type);

            //paramFiles = listGeneralStructure.OfType<CsvParamFile>().ToList();

            foreach (GeneralUseStructure sgs in listSequenceGenerationStructure)
            {
                this.dg = (DirectedGraph)sgs;
                List <String[]> sequence = this.GenerateTestCases();
                testPlan = populate.PopulateTestPlan(sequence, dg);
                //tcCount += testPlan.TestCases.Count;
                listPlan.Add(testPlan);
            }

            //GeneralTPGenerator(listPlan);

            foreach (TestPlanForTCC testPlan in listPlan)
            {
                GeneralUseStructure sc = (GeneralUseStructure)testPlan;
                listScript.Add(sc);
            }
            //TestCase.contWorkItemId = 1000;
            return(listScript);
        }
コード例 #2
0
        public TestPlanForTCC PopulateTestPlan(List <String[]> sequence, DirectedGraph dg)
        {
            //this.paramFiles = paramFiles;
            TestPlanForTCC testPlan = new TestPlanForTCC();

            PopulateTestCase(sequence, dg, testPlan);

            return(testPlan);
        }
コード例 #3
0
        public List <String[]> GenerateTestCases()
        {
            this.testPlan      = new TestPlanForTCC();
            this.testPlan.Name = dg.Name;

            List <String[]> testCases = new List <String[]> ();
            List <String[]> sequence  = new List <String[]> ();

            sequence = GetAllFinalSequences(this.dg.RootNode, true);

            //List<String[]> filteredSequences = FilterSequences(sequence);
            //testCases.AddRange(filteredSequences);
            testCases.AddRange(sequence);

            return(testCases);
        }
コード例 #4
0
        private void PopulateTestCase(List <String[]> sequence, DirectedGraph dg, TestPlanForTCC testPlan)
        {
            for (int k = 0; k < sequence.Count(); k++)
            {
                Edge        edge            = new Edge();
                List <Edge> edges           = new List <Edge> ();
                String[]    arraySequence   = sequence[k];
                int         maxUseCaseLines = int.MaxValue;
                foreach (String input in arraySequence)
                {
                    edge = GetEdge(input, dg, edge.NodeB);
                    if (edge != null)
                    {
                        edges.Add(edge);

                        foreach (KeyValuePair <String, String> pair in edge.Values)
                        {
                            //int aux = GetUsedFilesLineCount(pair.Value);
                            //if (maxUseCaseLines > aux)
                            {
                                //maxUseCaseLines = aux;
                            }
                        }
                    }
                }

                TestCaseForTCC testCase = null;

                do
                {
                    testCase = FillTestCase(dg, edges, testCase);
                    if (testCase != null)
                    {
                        testPlan.TestCases.Add(testCase);
                    }
                    //currLine++;
                } while (doAgain /*&& (currLine < maxLine)*/);
            }
        }
コード例 #5
0
        private void GenerateJUnitFromTestPlan(List <GeneralUseStructure> listPlanStructure, String path)
        {
            //path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\GeneratedTest.java";

            foreach (GeneralUseStructure planStructure in listPlanStructure)
            {
                TestPlanForTCC testPlan = (TestPlanForTCC)planStructure;
                StreamWriter   sw       = new StreamWriter(path + @"\YourClassTest.java");

                WriteImportsAndConstructor(sw);
                //sw.WriteLine("import org.junit.Before;");

                for (int i = 0; i < testPlan.TestCases.Count; i++)
                {
                    TestCaseForTCC testCase            = testPlan.TestCases[i];
                    int            maxTestCaseQuantity = 0;

                    List <TestStepForTCC> tsWithParameters = (from ts in testCase.TestSteps
                                                              where ts.Input.Contains(',')
                                                              select ts).ToList();

                    foreach (TestStepForTCC ts in tsWithParameters)
                    {
                        int testCaseQuantity = ts.Input.Split(',').Count();

                        if (testCaseQuantity > maxTestCaseQuantity)
                        {
                            maxTestCaseQuantity = testCaseQuantity;
                        }
                    }

                    List <TestStepForTCC> constructors = (from ts in testCase.TestSteps
                                                          where ts.ActionType.Equals("0")
                                                          select ts).ToList();

                    for (int j = 0; j < maxTestCaseQuantity; j++)
                    {
                        WriteTestCaseHeader(sw);

                        foreach (TestStepForTCC constructor in constructors)
                        {
                            String objectName = constructor.Receiver.ToLower();
                            sw.WriteLine("\t\t" + constructor.Receiver + " " + objectName + " = new " + constructor.Receiver + "();");
                        }

                        for (int k = 0; k < testCase.TestSteps.Count; k++)
                        {
                            TestStepForTCC step = testCase.TestSteps[k];
                            if (step.ActionType.Equals("2") || step.ActionType.Equals("0"))
                            {
                                continue;
                            }
                            else
                            {
                                //Método sem parâmetros
                                if (String.IsNullOrEmpty(step.Input))
                                {
                                    sw.WriteLine("\t\t" + step.Receiver.ToLower() + "." + step.Method + "();");
                                }
                                //Testando com apenas um conjunto de parâmetros
                                else if (!step.Input.Contains(','))
                                {
                                    String[] singleEntryParams = step.Input.Split(';');
                                    foreach (String singleEntryParam in singleEntryParams)
                                    {
                                        String singleEntryParamAux = singleEntryParam;

                                        if (singleEntryParam.Contains('{'))
                                        {
                                            singleEntryParamAux = singleEntryParamAux.Substring(1);
                                        }
                                        if (singleEntryParam.Contains('}'))
                                        {
                                            singleEntryParamAux = singleEntryParamAux.Substring(0, singleEntryParam.Length - 1);
                                        }
                                        //TO DO
                                    }
                                }
                                //Testando com diversos conjuntos de parâmetros
                                else
                                {
                                    MultipleInputData(sw, step, j);
                                }
                            }
                        }
                        sw.WriteLine("\t}");
                    }
                }
                sw.WriteLine("}");
                sw.Close();
            }
        }