Пример #1
0
        /// <summary>
        /// Generate test sequences using HSI method.
        /// </summary>
        public String[][] GenerateTestCases()
        {
            List <String[]> transitionCovers = new List <String[]>();
            List <String[]> testCases        = new List <String[]>();
            StateNode       tree             = GenerateTree(this.fsm.InitialState);

            //group transition covers into the same group.
            for (int i = 0; i < this.fsm.States.Count; i++)
            {
                TestPlan   plan = new TestPlan();
                String[][] transitionCover;
                //transitionCover = this.GetTransitionCover(this.fsm.States[i]);
                State     stateAux     = this.fsm.States[i];
                String    stateAuxName = stateAux.Name;
                StateNode aux          = tree.getState(stateAux);

                if (aux == null)
                {
                    throw new Exception("State not found: " + this.fsm.States[i]);
                }
                transitionCover = this.GetTransitionCover(aux);

                for (int j = 0; j < transitionCover.Length; j++)
                {
                    //not all input are allowed
                    try
                    {
                        String[] iii = transitionCover[j];
                        transitionCovers.Add(iii);
                    }
                    catch (IndexOutOfRangeException) { }
                }
            }

            //generate separating families
            String[][][] hsiSet = this.GetHsiSet();

            foreach (String[] transitionCover in transitionCovers)
            {
                State parentState = this.GetIdentifierState(transitionCover);
                int   stateIndex  = this.fsm.States.IndexOf(parentState);

                foreach (String[] s in hsiSet[stateIndex])
                {
                    if (s == null)
                    {
                        continue;
                    }

                    String[] sequence = new String[transitionCover.Length + s.Length];

                    //copy transition cover into sequence
                    for (int k = 0; k < transitionCover.Length; k++)
                    {
                        sequence[k] = transitionCover[k];
                    }

                    //add hsi element into sequence
                    for (int k = 0; k < s.Length; k++)
                    {
                        sequence[k + transitionCover.Length] = s[k];
                    }
                    testCases.Add(sequence);
                }
            }
            //remove duplicated sequences and prefix
            testCases = this.RemoveDuplicatedSequences(testCases);

            return(testCases.ToArray());
        }