private TestCase FillTestCase(Plets.Modeling.FiniteStateMachine.FiniteStateMachine machine, List <Transition> listTransition, TestCase testCase)
        {
            int      index = 1;
            TestStep testStep;

            testCase        = new TestCase(HttpUtility.UrlDecode(machine.Name));
            testCase.Title += "_" + TestCase.contWorkItemId;
            //testCase.TestCaseId = TestCase.contWorkItemId;
            testCase.WorkItemId = TestCase.contWorkItemId;
            TestCase.contWorkItemId++;
            testStep = new TestStep();
            testCase.WriteFirstLine = CheckTestStepTags(machine, testCase);
            usedFiles = new List <CsvParamFile> ();
            foreach (Transition tran in listTransition)
            {
                readFile = false;
                bool isCycle        = false;
                bool lastCycleTrans = false;
                if (tran.GetTaggedValue("TDlastCycleTrans") != null)
                {
                    lastCycleTrans = (tran.GetTaggedValue("TDcycleTran").Equals("true") ? true : false);
                }
                if (tran.GetTaggedValue("TDcycleTran") != null)
                {
                    isCycle = true;
                }
                if (lastCycleTrans)
                {
                    usedFiles = usedFiles.Distinct().ToList();
                    foreach (CsvParamFile csv in usedFiles)
                    {
                        csv.NextLine();
                    }
                    usedFiles.Clear();
                }
                if (isCycle)
                {
                    testStep                = new TestStep();
                    testStep.Index          = index.ToString();
                    testStep.Description    = GenerateDescription(tran);
                    testStep.ExpectedResult = GenerateExpectedResult(tran);
                    testCase.TestSteps.Add(testStep);
                    index++;
                }
                else
                {
                    testStep                = new TestStep();
                    testStep.Index          = index.ToString();
                    testStep.Description    = GenerateDescription(tran);
                    testStep.ExpectedResult = GenerateExpectedResult(tran);
                    testCase.TestSteps.Add(testStep);
                    index++;
                    if (readFile)
                    {
                        doAgain = true;
                    }
                }
            }
            return(testCase);
        }
        public TestPlan PopulateTestPlan(String[][] matriz, Plets.Modeling.FiniteStateMachine.FiniteStateMachine machine, List <CsvParamFile> paramFiles)
        {
            this.paramFiles = paramFiles;
            TestPlan testPlan = new TestPlan();

            PopulateTestCase(matriz, machine, testPlan);
            return(testPlan);
        }
        private Transition GetTransitionFSM(String input, Plets.Modeling.FiniteStateMachine.FiniteStateMachine fsm)
        {
            List <Transition> transition = fsm.Transitions.Where(x => x.Input.Equals(input)).ToList();

            foreach (Transition t in transition)
            {
                return(t);
            }
            return(null);
        }
        private void PopulateTestCase(String[][] matriz, Plets.Modeling.FiniteStateMachine.FiniteStateMachine machine, TestPlan testPlan)
        {
            for (int k = 0; k < matriz.Length; k++)
            {
                List <Transition> listTransition = new List <Transition> ();
                String[]          arraySequence  = matriz[k];
                int maxUseCaseLines = int.MaxValue;
                foreach (String input in arraySequence)
                {
                    Transition tran = new Transition();
                    tran = GetTransitionFSM(input, machine);
                    if (tran != null)
                    {
                        listTransition.Add(tran);

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

                TestCase testCase = null;
                if (maxUseCaseLines == int.MaxValue)
                {
                    ResetParamFilesPointers();
                }
                else
                {
                    ResetParamFilesPointers(maxUseCaseLines);
                }

                do
                {
                    testCase = FillTestCase(machine, listTransition, testCase);
                    if (testCase != null)
                    {
                        testPlan.TestCases.Add(testCase);
                    }
                    currLine++;
                } while (doAgain && (currLine < maxLine));
            }
        }
예제 #5
0
        public override List <GeneralUseStructure> GenerateSequence(List <GeneralUseStructure> listGeneralStructure, ref int tcCount, StructureType type)
        {
            //FUNC
            GenerateTestPlan populate1 = new GenerateTestPlan();
            //PERF
            GenerateTestSuit populate2 = new GenerateTestSuit();

            List <TestPlan>            listPlan   = new List <TestPlan> ();
            List <GeneralUseStructure> listScript = new List <GeneralUseStructure> ();
            GeneralUseStructure        modelGeneralUseStructure        = listGeneralStructure.FirstOrDefault();
            List <GeneralUseStructure> listSequenceGenerationStructure = base.ConvertStructure(listGeneralStructure, type);
            List <TestStep>            listTestStep = new List <TestStep> ();

            foreach (GeneralUseStructure sgs in listSequenceGenerationStructure)
            {
                this.fsm = (Plets.Modeling.FiniteStateMachine.FiniteStateMachine)sgs;
                String[][] sequence = this.GenerateTestCases();
                //Verify what to do in this step when using PerformanceTool
                List <CsvParamFile> listCSV = listGeneralStructure.OfType <CsvParamFile> ().ToList();
                //FUNC
                TestPlan plan = populate1.PopulateTestPlan(sequence, fsm, listCSV);
                //PERF
                TestSuit suit = populate2.PopulateTestSuit(sequence, fsm, modelGeneralUseStructure);
                tcCount         += plan.TestCases.Count;
                plan.NameUseCase = this.fsm.NameUseCase;
                listPlan.Add(plan);
            }

            GeneralTPGenerator(listPlan, listTestStep);

            foreach (TestPlan testPlan in listPlan)
            {
                GeneralUseStructure sc = (TestPlan)testPlan;
                //sc.NameUseCase = testPlan.NameUseCase;
                listScript.Add(sc);
            }

            return(listScript);
        }
        private Boolean CheckTestStepTags(Plets.Modeling.FiniteStateMachine.FiniteStateMachine machine, TestCase testCase)
        {
            Boolean ret = false;

            foreach (KeyValuePair <String, String> pair in machine.TaggedValues)
            {
                switch (pair.Key)
                {
                case "TDSTATE":
                    testCase.TDstate = HttpUtility.UrlDecode(pair.Value);
                    break;

                case "TDASSIGNED":
                    testCase.TDassigned = HttpUtility.UrlDecode(pair.Value);
                    break;

                case "TDREASON":
                    testCase.TDreason = HttpUtility.UrlDecode(pair.Value);
                    break;

                case "TDITERATIONPATH":
                    testCase.TDiterationPath = HttpUtility.UrlDecode(pair.Value);
                    break;

                case "TDAREAPATH":
                    testCase.TDareaPath = HttpUtility.UrlDecode(pair.Value);
                    break;

                case "TDAPPLICATION":
                    testCase.TDapplication = HttpUtility.UrlDecode(pair.Value);
                    break;

                case "TDCOMPLEXITY":
                    testCase.TDcomplexity = HttpUtility.UrlDecode(pair.Value);
                    break;

                case "TDRISKS":
                    testCase.TDrisks = HttpUtility.UrlDecode(pair.Value);
                    break;

                case "TDTCLIFECYCLE":
                    testCase.TDtcLifecycle = HttpUtility.UrlDecode(pair.Value);
                    break;

                case "TDLIFECYCLETYPE":
                    testCase.TDlifecycleType = HttpUtility.UrlDecode(pair.Value);
                    break;

                case "TDTCTEAMUSAGE":
                    testCase.TDtcTeamUsage = HttpUtility.UrlDecode(pair.Value);
                    break;

                case "TDPOSTCONDITIONS":
                    testCase.TDpostConditions = HttpUtility.UrlDecode(pair.Value);
                    ret = true;
                    break;

                case "TDPRECONDITIONS":
                    testCase.TDpreConditions = HttpUtility.UrlDecode(pair.Value);
                    ret = true;
                    break;

                default:
                    break;
                }
            }
            return(ret);
        }
예제 #7
0
        private TestCase FillTestCase(Plets.Modeling.FiniteStateMachine.FiniteStateMachine machine, List <Transition> listTransition)
        {
            TestCase testCase = new TestCase();

            testCase.Name        = machine.Name;
            testCase.Probability = actualTestCaseProb;
            Transaction transaction = null;
            bool        existsLane  = false;

            foreach (Transition t in listTransition)
            {
                State s = machine.States.Where(x => x.Name.Equals(t.SourceState.Name)).FirstOrDefault();
                try {
                    existsLane = !String.IsNullOrEmpty(s.TaggedValues["Lane"]);
                } catch {
                    existsLane = false;
                }
                if (existsLane)
                {
                    List <Transaction> transactions = testCase.Transactions.Where(x => x.Name.Equals(s.TaggedValues["Lane"])).ToList();
                    if (transactions.Count == 0)
                    {
                        transaction      = new Transaction();
                        transaction.Name = s.TaggedValues["Lane"];
                        Subtransaction subtransaction = new Subtransaction();
                        subtransaction.Name = t.SourceState.Name;
                        Request request = new Request();
                        request.Name = t.SourceState.Name;
                        GetRequestTags(t, request);
                        subtransaction.Begin = request;
                        subtransaction.End   = request;
                        transaction.Subtransactions.Add(subtransaction);
                        testCase.Transactions.Add(transaction);
                    }
                    else
                    {
                        transaction = transactions.FirstOrDefault();
                        Subtransaction subtransaction = new Subtransaction();
                        subtransaction.Name = t.SourceState.Name;
                        Request request = new Request();
                        request.Name = t.SourceState.Name;
                        GetRequestTags(t, request);
                        subtransaction.Begin = request;
                        subtransaction.End   = request;
                        transaction.Subtransactions.Add(subtransaction);
                    }
                }
                else
                {
                    transaction      = new Transaction();
                    transaction.Name = t.SourceState.Name;
                    Request request = new Request();
                    GetRequestTags(t, request);
                    transaction.Begin = request;
                    transaction.End   = request;
                    testCase.Transactions.Add(transaction);
                }
                AddRequestsToTestCase(testCase, t);
            }

            return(testCase);
        }
예제 #8
0
        public TestSuit PopulateTestSuit(String[][] matriz, Plets.Modeling.FiniteStateMachine.FiniteStateMachine machine, GeneralUseStructure modelGeneralUseStructure)
        {
            UmlModel model = (UmlModel)modelGeneralUseStructure;

            foreach (UmlUseCaseDiagram ucDiagram in model.Diagrams.OfType <UmlUseCaseDiagram> ())
            {
                UmlUseCase equivalentUC = ucDiagram.UmlObjects.OfType <UmlUseCase> ().Where(x => x.Name.Equals(machine.Name)).FirstOrDefault();

                foreach (UmlActor actor in ucDiagram.UmlObjects.OfType <UmlActor> ())
                {
                    foreach (UmlAssociation association in ucDiagram.UmlObjects.OfType <UmlAssociation> ())
                    {
                        if ((association.End1.Equals(actor) && association.End2.Equals(equivalentUC)) || (association.End1.Equals(equivalentUC) && association.End2.Equals(actor)))
                        {
                            try {
                                actualTestCaseProb = float.Parse(association.GetTaggedValue("TDprob"), CultureInfo.InvariantCulture);
                            } catch {
                                actualTestCaseProb = 0;
                            }
                            if (suit.Scenarios.Count < 1)
                            {
                                scenario      = new Scenario();
                                scenario.Name = actor.Name;
                                AddScenarioInformation(actor);
                                suit.Scenarios.Add(scenario);
                            }

                            foreach (Scenario scenarioAlreadyAdded in suit.Scenarios)
                            {
                                if (actor.Name.Equals(scenarioAlreadyAdded.Name))
                                {
                                    scenario = scenarioAlreadyAdded;
                                }
                                else
                                {
                                    scenario      = new Scenario();
                                    scenario.Name = actor.Name;
                                    AddScenarioInformation(actor);
                                    suit.Scenarios.Add(scenario);
                                }
                            }
                        }
                    }
                }
            }

            for (int k = 0; k < matriz.Length; k++)
            {
                List <Transition> listTransition = new List <Transition> ();
                String[]          arraySequence  = matriz[k];

                foreach (String input in arraySequence)
                {
                    Transition tran = new Transition();
                    tran = GetTransitionFSM(input, machine);

                    if (tran != null)
                    {
                        listTransition.Add(tran);
                    }
                }
                scenario.TestCases.Add(FillTestCase(machine, listTransition));
            }
            return(suit);
        }