/// <summary>
        /// Creates a section for a given test case
        /// </summary>
        /// <param name="runner">The runner to be used to execute the tests</param>
        /// <param name="aFrame">Frame to be displayed</param>
        /// <param name="aReportConfig">The report configuration containing display details</param>
        /// <param name="activatedRuleConditions">The list that will contain the rules activated by this test case</param>
        /// <returns></returns>
        public void CreateTestCaseSection(DataDictionary.Tests.Runner.Runner runner, TestCase aTestCase, TestsCoverageReportHandler aReportConfig, HashSet <RuleCondition> activatedRuleConditions, bool createPdf)
        {
            AddSubParagraph("Test case " + aTestCase.Name);

            if (aTestCase.Requirements.Count > 0)
            {
                AddParagraph("This test case verifies the following requirements");
                foreach (DataDictionary.ReqRef reqRef in aTestCase.Requirements)
                {
                    string text = "Requirement " + reqRef.Name;
                    if (!Utils.Utils.isEmpty(reqRef.Comment))
                    {
                        text = text + " : " + reqRef.Comment;
                    }
                    AddListItem(text);
                }
            }

            runner.RunUntilStep(null);
            activatedRuleConditions.UnionWith(runner.EventTimeLine.GetActivatedRules());

            string title = "Test case " + aTestCase.Name;

            CreateTable(title,
                        runner.EventTimeLine.GetActivatedRules(),
                        aReportConfig.Dictionary.ImplementedRules,
                        aReportConfig.AddActivatedRulesInTestCases,
                        aReportConfig.AddNonCoveredRulesInTestCases);

            if (createPdf && aReportConfig.AddSteps)
            {
                foreach (Step step in aTestCase.Steps)
                {
                    if (step.SubSteps.Count > 0)
                    {
                        AddSubParagraph(String.Format("Step {0}", step.Name));

                        DataDictionary.Tests.SubStep firstSubStep = step.SubSteps[0] as DataDictionary.Tests.SubStep;
                        DataDictionary.Tests.SubStep lastSubStep  = step.SubSteps[step.SubSteps.Count - 1] as DataDictionary.Tests.SubStep;
                        double start = runner.EventTimeLine.GetSubStepActivationTime(firstSubStep);
                        double end   = runner.EventTimeLine.GetNextSubStepActivationTime(lastSubStep);
                        List <RuleCondition> activatedRules = runner.EventTimeLine.GetActivatedRulesInRange(start, end);

                        CreateStepTable(runner, step, aTestCase.Dictionary.ImplementedRules.Count, activatedRules, aReportConfig);
                        if (aReportConfig.AddLog)
                        {
                            List <DataDictionary.Tests.Runner.Events.ModelEvent> events = runner.EventTimeLine.GetEventsInRange((uint)start, (uint)end);
                            foreach (ModelEvent ev in events)
                            {
                                AddCode(ev.ToString());
                            }
                        }
                        CloseSubParagraph();
                    }
                }
            }
            CloseSubParagraph();
        }
 /// <summary>
 /// Executes the tests in the background thread
 /// </summary>
 /// <param name="arg"></param>
 public override void ExecuteWork()
 {
     if (Window != null)
     {
         DataDictionary.Tests.SubSequence subSequence = TestCase.Enclosing as DataDictionary.Tests.SubSequence;
         if (subSequence != null)
         {
             DataDictionary.Tests.Runner.Runner runner = new DataDictionary.Tests.Runner.Runner(subSequence);
             runner.RunUntilStep(null);
         }
     }
 }
Example #3
0
        /// <summary>
        /// Handles a run event on this step
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void RunForExpectationsHandler(object sender, EventArgs args)
        {
            CheckRunner();

            Window window = BaseForm as Window;

            if (window != null)
            {
                DataDictionary.Tests.Runner.Runner runner = window.getRunner(Item.TestCase.SubSequence);

                runner.RunUntilStep(Item);
                foreach (DataDictionary.Tests.SubStep subStep in Item.SubSteps)
                {
                    runner.SetupSubStep(subStep);
                    if (!subStep.getSkipEngine())
                    {
                        runner.RunForBlockingExpectations(true);
                    }
                }
                window.MDIWindow.Refresh();
            }
        }
Example #4
0
        /// <summary>
        /// Perform all functional tests defined in the .EFS file provided
        /// </summary>
        /// <param name="args"></param>
        /// <returns>the error code of the program</returns>
        static int Main(string[] args)
        {
            int retVal = 0;

            try
            {
                Console.Out.WriteLine("EFS Tester");

                // Load the dictionaries provided as parameters
                EFSSystem efsSystem = EFSSystem.INSTANCE;
                foreach (string arg in args)
                {
                    Console.Out.WriteLine("Loading dictionary " + arg);
                    Dictionary dictionary = Util.load(arg, efsSystem);
                    if (dictionary == null)
                    {
                        Console.Out.WriteLine("Cannot load dictionary " + arg);
                        return(-1);
                    }
                }

                // Perform functional test for each loaded dictionary
                foreach (Dictionary dictionary in efsSystem.Dictionaries)
                {
                    Console.Out.WriteLine("Processing tests from dictionary " + dictionary.Name);
                    foreach (DataDictionary.Tests.Frame frame in dictionary.Tests)
                    {
                        Console.Out.WriteLine("Executing frame " + frame.FullName);
                        foreach (DataDictionary.Tests.SubSequence subSequence in frame.SubSequences)
                        {
                            Console.Out.WriteLine("Executing sub sequence " + subSequence.FullName);
                            DataDictionary.Tests.Runner.Runner runner = new DataDictionary.Tests.Runner.Runner(subSequence);
                            runner.RunUntilStep(null);

                            bool failed = false;
                            foreach (DataDictionary.Tests.Runner.Events.Expect expect in runner.FailedExpectations())
                            {
                                Console.Out.WriteLine(" failed : " + expect.Message);
                                DataDictionary.Tests.TestCase testCase = Utils.EnclosingFinder <DataDictionary.Tests.TestCase> .find(expect.Expectation);

                                if (testCase.ImplementationCompleted)
                                {
                                    Console.Out.WriteLine(" !Unexpected failed expectation: " + expect.Message);
                                    failed = true;
                                }
                                else
                                {
                                    Console.Out.WriteLine(" .Expected failed expectation: " + expect.Message);
                                }
                            }
                            if (failed)
                            {
                                Console.Out.WriteLine("  -> Failed");
                                retVal = -1;
                            }
                            else
                            {
                                Console.Out.WriteLine("  -> Success");
                            }
                        }
                    }
                }
            }
            finally
            {
                DataDictionary.Util.UnlockAllFiles();
            }

            return(retVal);
        }
        /// <summary>
        /// Perform all functional tests defined in the .EFS file provided
        /// </summary>
        /// <param name="args"></param>
        /// <returns>the error code of the program</returns>
        static int Main(string[] args)
        {
            int retVal = 0;

            try
            {

                Console.Out.WriteLine("EFS Tester");

                // Load the dictionaries provided as parameters
                EFSSystem efsSystem = EFSSystem.INSTANCE;
                foreach (string arg in args)
                {
                    Console.Out.WriteLine("Loading dictionary " + arg);
                    Dictionary dictionary = Util.load(arg, efsSystem);
                    if (dictionary == null)
                    {
                        Console.Out.WriteLine("Cannot load dictionary " + arg);
                        return -1;
                    }
                }

                // Perform functional test for each loaded dictionary
                foreach (Dictionary dictionary in efsSystem.Dictionaries)
                {
                    Console.Out.WriteLine("Processing tests from dictionary " + dictionary.Name);
                    foreach (DataDictionary.Tests.Frame frame in dictionary.Tests)
                    {
                        Console.Out.WriteLine("Executing frame " + frame.FullName);
                        foreach (DataDictionary.Tests.SubSequence subSequence in frame.SubSequences)
                        {
                            Console.Out.WriteLine("Executing sub sequence " + subSequence.FullName);
                            DataDictionary.Tests.Runner.Runner runner = new DataDictionary.Tests.Runner.Runner(subSequence);
                            runner.RunUntilStep(null);

                            bool failed = false;
                            foreach (DataDictionary.Tests.Runner.Events.Expect expect in runner.FailedExpectations())
                            {
                                Console.Out.WriteLine(" failed : " + expect.Message);
                                DataDictionary.Tests.TestCase testCase = Utils.EnclosingFinder<DataDictionary.Tests.TestCase>.find(expect.Expectation);
                                if (testCase.ImplementationCompleted)
                                {
                                    Console.Out.WriteLine(" !Unexpected failed expectation: " + expect.Message);
                                    failed = true;
                                }
                                else
                                {
                                    Console.Out.WriteLine(" .Expected failed expectation: " + expect.Message);
                                }

                            }
                            if (failed)
                            {
                                Console.Out.WriteLine("  -> Failed");
                                retVal = -1;
                            }
                            else
                            {
                                Console.Out.WriteLine("  -> Success");
                            }
                        }
                    }
                }
            }
            finally
            {
                DataDictionary.Util.UnlockAllFiles();
            }

            return retVal;
        }