Exemple #1
0
 /// <summary>
 /// Creates an instance of the conformance tester for an IUT stepper.
 /// </summary>
 /// <param name="model">given model stepper</param>
 /// <param name="impl">given implementation stepper</param>
 public ConformanceTester(IStrategy model, IStepper impl)
 {
     this.model = model;
     this.impl = impl;
     //set the callback in the implementation
     //if the implementation implements IAsyncStepper
     IAsyncStepper implWithObs = impl as IAsyncStepper;
     if (implWithObs != null)
     {
         TimedQueue<Action> obs = new TimedQueue<Action>();
         this.observations = obs;
         implWithObs.SetObserver(obs.Enqueue);
     }
     this.testResultNotifier = this.DefaultTestResultNotifier;
     this.testerActionTimeout = delegate(IState state, CompoundTerm action) { return defaultTimeSpan; };
     this.testerActionSymbols = model.ActionSymbols;
     this.cleanupActionSymbols = Set<Symbol>.EmptySet;
     this.internalActionSymbols = Set<Symbol>.EmptySet;
     this.RandomSeed = new Random().Next();
     this.worker = new TimedWorker();
 }
Exemple #2
0
        /// <summary>
        /// Call RunTestCase runsCnt times, reset in between runs.
        /// </summary>
        /// <exception cref="ConformanceTesterException">Is thrown when Run does not finish normally</exception>
        public void Run()
        {
            bool reset = false;
            try
            {
                int run = 0;
                while ((runsCnt <= 0) || run < runsCnt)
                {
                    TestResult testResult = RunTestCase(run);

                    // Tests results summary metrics
                    if (testResult.verdict == Verdict.Failure)
                        ++totalFailedTests;

                    // Requirements metrics
                    totalExecutedRequirements = totalExecutedRequirements.Union(testResult.executedRequirements);

                    if (!this.testResultNotifier(testResult))
                    {
                        Reset();

                        //Metrics
                        AddMetricsToEndOfLog();

                        return;
                    }
                    Reset();
                    run += 1;

                    // Tests results summary metrics
                    totalExecutedTests = run;
                }

                // Metrics
                AddMetricsToEndOfLog();
            }
            catch (Exception e)
            {
                if (e.Message != "Reset failed.")
                    reset = true;
                if (e is ConformanceTesterException)
                {
                    throw;
                }
                throw new ConformanceTesterException("Run failed. " + e.Message);
            }
            finally
            {
                //dispose of the worker thread pool
                worker.Dispose();
                if (reset)
                    Reset();
                worker = null;
            }
        }