Package nz.ac.waikato.modeljunit

Examples of nz.ac.waikato.modeljunit.Tester


   */
  public static void main(String[] args) throws FileNotFoundException
  {
    final int experiments = 100;
    TimedModel model = new TimedModel(new SimpleTimedLight());
    Tester tester = new RandomTester(model);
    //tester.addListener(new VerboseListener());
    double origProb = model.getTimeoutProbability();
    model.setTimeoutProbability(0.3); // while exploring the FSM
    GraphListener graph = tester.buildGraph();
    model.setTimeoutProbability(origProb);
    graph.printGraphDot("SimpleTimedLight.dot");
    System.out.println("FSM has " + graph.getGraph().numVertices() + " states and "
        + graph.getGraph().numEdges() + " transitions");
    CoverageMetric metric = tester.addCoverageMetric(new TransitionCoverage());
    for (double prob = 0.1; prob < 0.99; prob += 0.1) {
      model.setTimeoutProbability(prob);
      double totalSteps = 0.0;
      int totalTime = 0; // sum of all the totalTimes.
      for (int seed = 0; seed < experiments; seed++) {
        int testSeqTime = 0;
        int lastTime = 0; // the time after the last transition
        metric.clear();
        tester.reset();
        tester.setRandom(new Random(seed));
        int count = 0;
        while (metric.getPercentage() < 100.0) {
          tester.generate(1);
          if (model.getTime() > lastTime) {
            lastTime = model.getTime();
          } else {
            testSeqTime += lastTime;
            //System.out.println("added " + lastTime + " secs");
View Full Code Here


  }

  public static void main(String[] args)
  {
    TimedModel model = new TimedModel(new TrafficLight());
    Tester tester = new RandomTester(model);
    //tester.addListener("verbose");
    //GraphListener graphListener = tester.buildGraph();
   
    try {
      for (int count = 0; count < 1000000; count += 1000) {
        tester.generate(1000);
        System.out.println(count);
      }
      //graphListener.printGraphDot("TrafficLight.dot");
    }
    catch (Exception ex) {
View Full Code Here

        + " New State: " + getState());
  }

  public static void main(String[] args)
  {
    Tester tester = new GreedyTester(new AlarmClockOld());
    System.out.println("------------------------");
    tester.setRandom(new Random());
    tester.generate(100);
    GraphListener listener = tester.buildGraph();
    try {
      listener.printGraphDot("OriginalAlarmClock.dot");
    }
    catch (FileNotFoundException e) {
      e.printStackTrace();
View Full Code Here

  /** An example of generating tests from this model. */
  public static void main(String[] args)
  {
    Set<String> sut = new StringSetBuggy(); // StringSetBuggy();
    Tester tester = new GreedyTester(new SimpleSetWithAdaptor(sut));
    //tester.buildGraph(); // to get better statistics
    tester.addListener(new VerboseListener());
   
    // uncoment this line if you want to stop when the first error is found.
    // tester.addListener(new StopOnFailureListener());
   
    tester.addCoverageMetric(new TransitionCoverage());
    tester.generate(50);
    tester.printCoverage();
  }
View Full Code Here

    return result;
  }

  public static void main(String[] args) throws FileNotFoundException
  {
    Tester tester = new RandomTester(new ECinema());
    // The guards make this a more difficult graph to explore, but we can
    // increase the default maximum search to complete the exploration.
    GraphListener graph = tester.buildGraph(100000);
    graph.printGraphDot("ecinema.dot");
    CoverageMetric trans = tester.addCoverageMetric(new TransitionCoverage());
    CoverageMetric trpairs = tester.addCoverageMetric(new TransitionPairCoverage());
    CoverageMetric states = tester.addCoverageMetric(new StateCoverage());
    CoverageMetric actions = tester.addCoverageMetric(new ActionCoverage());
    tester.addListener("verbose");
    // this illustrates how to generate tests upto a given level of coverage.
    int steps = 0;
    while (actions.getPercentage() < 100 /* || steps < 1000*/) {
      tester.generate();
      steps++;
    }
    System.out.println("Generated "+steps+" steps.");
    tester.printCoverage();
  }
View Full Code Here

   *  but we write it as main so that it is easy to run.
   */
  public static void main(String[] args)
  {
    Set<String> sut = new HashSet<String>();
    Tester tester = new GreedyTester(new SmartSetAdaptor(sut));
    tester.addListener("verbose");
    tester.generate(100);
  }
View Full Code Here

      String line = input.readLine();
      if (line == null)
        break;
      if (line.equals("graph")) {
        quidonc.out.println("Building FSM graph...");
        Tester tester = new GreedyTester(quidonc);
        GraphListener graph = tester.buildGraph();
        graph.printGraphDot("QuiDonc.dot");
        quidonc.out.println("Printed FSM graph to QuiDonc.dot.");
        quidonc.out.println("Use dotty or dot from http://www.graphviz.org"
            + " to view/transform the graph.");
      }
View Full Code Here

  }

  public void testSet() throws IOException
  {
    Set<String> sut = new StringSet();
    Tester tester = new GreedyTester(new SimpleSetWithAdaptor(sut));
    tester.addCoverageMetric(new TransitionCoverage());
    tester.addListener(new VerboseListener());
    tester.addListener(new StopOnFailureListener());
    tester.generate(60);
    tester.printCoverage(); // print the model coverage information
  }
View Full Code Here


  /** An example of generating tests from this model. */
  public static void main(String[] args) throws IOException
  {
    Tester tester = new GreedyTester(new LargeSet(2));
    tester.buildGraph(100000);
    CoverageHistory hist = new CoverageHistory(new TransitionCoverage(), 1);
    tester.addCoverageMetric(hist);
    tester.addListener("verbose");
    while (hist.getPercentage() < 99.0)
      tester.generate();
    System.out.println("Transition Coverage ="+hist.toString());
    System.out.println("History = "+hist.toCSV());
  }
View Full Code Here

   *  We also report the transition coverage of the model.
   */
  public static void main(String args[])
  {
    // create our model and a test generation algorithm
    Tester tester = new RandomTester(new FSM());

    // build the complete FSM graph for our model, just to ensure
    // that we get accurate model coverage metrics.
    tester.buildGraph();

    // set up our favourite coverage metric
    CoverageMetric trCoverage = new TransitionCoverage();
    tester.addListener(trCoverage);

    // ask to print the generated tests
    tester.addListener("verbose");

    // generate a small test suite of 20 steps (covers 4/5 transitions)
    tester.generate(20);

    tester.getModel().printMessage(trCoverage.getName() + " was "
        + trCoverage.toString());
  }
View Full Code Here

TOP

Related Classes of nz.ac.waikato.modeljunit.Tester

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.