Examples of CoverageHistory


Examples of nz.ac.waikato.modeljunit.coverage.CoverageHistory

  /** This tests a random walk, plus transition coverage */
  public static void testRandomWalk()
  {
    output_.write("STARTING RANDOM\n");
    Tester tester = new RandomTester(quidonc);
    CoverageHistory metric = new CoverageHistory(new TransitionCoverage(), 1);
    tester.addListener(metric);
    tester.generate(100);
    int coverage = metric.getCoverage();
    List<Integer> hist = metric.getHistory();
    Assert.assertNotNull(hist);
    output_.write("transhist="+metric.toCSV()+"\n");
    Assert.assertEquals(16, coverage);
    Assert.assertEquals(-1, metric.getMaximum());
    Assert.assertEquals("Incorrect history size.", 101, hist.size());
    Assert.assertEquals(new Integer(0), hist.get(0));
    Assert.assertEquals(new Integer(coverage), hist.get(hist.size() - 1));
    // System.out.println(output_.toString());
  }
View Full Code Here

Examples of nz.ac.waikato.modeljunit.coverage.CoverageHistory

  /** This tests a greedy random walk, plus transition coverage */
  public static void testGreedyRandomWalk()
  {
    output_.write("STARTING GREEDY\n");
    Tester tester = new GreedyTester(new QuiDonc());
    CoverageHistory metric = new CoverageHistory(new TransitionCoverage(), 1);
    tester.addListener(metric);
    tester.generate(100);
    int coverage = metric.getCoverage();
    List<Integer> hist = metric.getHistory();
    Assert.assertNotNull(hist);
    output_.write("transhist="+metric.toCSV()+"\n");
    Assert.assertEquals(17, coverage);
    Assert.assertEquals(17, metric.getMaximum());
    Assert.assertEquals("Incorrect history size.", 101, hist.size());
    Assert.assertEquals(new Integer(0), hist.get(0));
    Assert.assertEquals(new Integer(coverage), hist.get(hist.size() - 1));
    // System.out.println(output_.toString());
  }
View Full Code Here

Examples of nz.ac.waikato.modeljunit.coverage.CoverageHistory

  /** This tests an all-round-trips walk, plus transition coverage */
  public static void testAllRoundTrips()
  {
    output_.write("STARTING ALL ROUND TRIPS\n");
    Tester tester = new AllRoundTester(new QuiDonc());
    CoverageHistory metric = new CoverageHistory(new TransitionCoverage(), 1);
    tester.addCoverageMetric(metric);
    tester.generate(100);
    int coverage = metric.getCoverage();
    List<Integer> hist = metric.getHistory();
    Assert.assertNotNull(hist);
    output_.write("transhist="+metric.toCSV()+"\n");
    Assert.assertEquals(12, coverage);
    Assert.assertEquals(-1, metric.getMaximum());
    // TODO: Assert.assertEquals("Incorrect history size.", 101, hist.size());
    Assert.assertEquals(new Integer(0), hist.get(0));
    Assert.assertEquals(new Integer(coverage), hist.get(hist.size() - 1));
    // System.out.println(output_.toString());
  }
View Full Code Here

Examples of nz.ac.waikato.modeljunit.coverage.CoverageHistory

  /** This tests a random walk, plus ActionCoverage metric with history.*/
  public static void testRandomWalk()
  {
    ModelTestCase model = new ModelTestCase(new FSM());
    CoverageHistory metric = new CoverageHistory(new ActionCoverage(), 1);
    model.addCoverageMetric(metric);
    model.randomWalk(4); // 4 transitions plus a few resets
    int coverage = metric.getCoverage();
    Assert.assertEquals(3, coverage);
    Assert.assertEquals(-1, metric.getMaximum()); // unknown.
    List<Integer> hist = metric.getHistory();
    Assert.assertNotNull(hist);
    Assert.assertEquals("Incorrect history size.", 7, hist.size());
    Assert.assertEquals(new Integer(0), hist.get(0));
    Assert.assertEquals(new Integer(coverage), hist.get(hist.size() - 1));

    // we print this just for interest
    //    System.out.println("Action coverage: " + metric.getPercentage());
    //    System.out.print("History: ");
    //    for (Integer cov : metric.getHistory())
    //      System.out.print(cov + ", ");
    //    System.out.println();

    model.resetCoverageMetrics();
    hist = metric.getHistory();
    Assert.assertNotNull(hist);
    Assert.assertEquals("History not reset.", 1, hist.size());
    Assert.assertEquals(new Integer(0), hist.get(0));
   
    model.removeCoverageMetric(metric);
View Full Code Here

Examples of nz.ac.waikato.modeljunit.coverage.CoverageHistory

  /** This tests a greedy random walk, plus TransitionCoverage metric with history */
  public static void testGreedyRandomWalk()
  {
    ModelTestCase model = new ModelTestCase(new FSM());
    CoverageHistory metric = new CoverageHistory(new TransitionCoverage(), 1);
    model.addCoverageMetric(metric);
    model.greedyRandomWalk(7); // 7 transitions plus a few resets
    int coverage = metric.getCoverage();
    Assert.assertEquals(5, coverage);
    Assert.assertEquals(-1, metric.getMaximum());
    List<Integer> hist = metric.getHistory();
    Assert.assertNotNull(hist);
    Assert.assertEquals("Incorrect history size.", 10, hist.size());
    Assert.assertEquals(new Integer(0), hist.get(0));
    Assert.assertEquals(new Integer(coverage), hist.get(hist.size() - 1));
  }
View Full Code Here

Examples of nz.ac.waikato.modeljunit.coverage.CoverageHistory

    RandomTester tester = new RandomTester(new FSM());
    //System.out.println("action0="+tester.getModel().getActionName(0));
    //System.out.println("action1="+tester.getModel().getActionName(1));
    //System.out.println("action2="+tester.getModel().getActionName(2));
    //System.out.println("action3="+tester.getModel().getActionName(3));
    CoverageHistory metric =
      new CoverageHistory(new ActionCoverage(), 1);
    tester.addListener(metric);
   
    Random random = new Random(3);
    tester.setRandom(random);
    tester.generate(5);
    int coverage = metric.getCoverage();
    Assert.assertEquals(1, coverage);
    Assert.assertEquals(4, metric.getMaximum());
    List<Integer> hist = metric.getHistory();
    Assert.assertNotNull(hist);
    Assert.assertEquals("Incorrect history size.", 6, hist.size());
    Assert.assertEquals(new Integer(0), hist.get(0));
    Assert.assertEquals(new Integer(coverage), hist.get(hist.size() - 1));

    // we print this just for interest
    //    System.out.println("Action coverage: " + metric.getPercentage());
    //    System.out.print("History: ");
    //    for (Integer cov : metric.getHistory())
    //      System.out.print(cov + ", ");
    //    System.out.println();

    metric.clear();
    hist = metric.getHistory();
    Assert.assertNotNull(hist);
    Assert.assertEquals("History not reset.", 1, hist.size());
    Assert.assertEquals(new Integer(0), hist.get(0));
  }
View Full Code Here

Examples of nz.ac.waikato.modeljunit.coverage.CoverageHistory

  /** This tests a random walk, plus ActionCoverage metric with history.*/
  public static void testGreedyWalk()
  {
    Tester tester = new GreedyTester(new FSM());
    tester.addListener(new VerboseListener());
    CoverageHistory metric =
      new CoverageHistory(new ActionCoverage(), 1);
    tester.addCoverageMetric(metric);
    tester.setRandom(new Random(1));
    tester.generate(7);
    int coverage = metric.getCoverage();
    Assert.assertEquals(4, coverage);
    Assert.assertEquals(4, metric.getMaximum());
    List<Integer> hist = metric.getHistory();
    Assert.assertNotNull(hist);
    Assert.assertEquals("Incorrect history size.", 8, hist.size());
    Assert.assertEquals(new Integer(0), hist.get(0));
    Assert.assertEquals(new Integer(coverage), hist.get(hist.size() - 1));
    Assert.assertEquals("Similar to a random walk, but always takes an unexplored" +
        " transition if one is enabled in the current state. " +
        " This gives faster transition coverage initially, then" +
        " has the same behaviour as a random walk.", tester.getDescription());

    // we print this just for interest
    //    System.out.println("Action coverage: " + metric.getPercentage());
    //    System.out.print("History: ");
    //    for (Integer cov : metric.getHistory())
    //      System.out.print(cov + ", ");
    //    System.out.println();

    metric.clear();
    hist = metric.getHistory();
    Assert.assertNotNull(hist);
    Assert.assertEquals("History not reset.", 1, hist.size());
    Assert.assertEquals(new Integer(0), hist.get(0));
  }
View Full Code Here

Examples of nz.ac.waikato.modeljunit.coverage.CoverageHistory

  {
    RandomTester tester = new RandomTester(new FSM());
    tester.buildGraph();
    tester.setResetProbability(0.9);
    CoverageMetric trCover = new TransitionCoverage();
    CoverageHistory hist = new CoverageHistory(trCover,1);
    tester.addListener(hist);
    tester.generate(40);
    // the random walk should choose reset almost all the time
    // so should not get much past the first transition.
    Assert.assertEquals(41, hist.getHistory().size());
    Assert.assertEquals(1, trCover.getCoverage());
  }
View Full Code Here

Examples of nz.ac.waikato.modeljunit.coverage.CoverageHistory

{
  /** This tests a random walk, plus TransitionCoverage metric with history.*/
  public static void testAllRoundWalk()
  {
    AllRoundTester tester = new AllRoundTester(new FSM());
    CoverageHistory metric = new CoverageHistory(new TransitionCoverage(), 1);
    //tester.addListener(new VerboseListener());
    tester.addCoverageMetric(metric);
    tester.setLoopTolerance(1);
    tester.setRandom(new Random(3));
    tester.generate(10);
    int coverage = metric.getCoverage();
    Assert.assertEquals("Loop-limited Greedy Random Walk", tester.getName());
    Assert.assertEquals("This tester limits another tester (Greedy Random Walk)" +
        " so that it goes around loops a maximum number of times" +
        " (once by default).", tester.getDescription());
    Assert.assertEquals(1, tester.getLoopTolerance());
    Assert.assertEquals(5, coverage);
    Assert.assertEquals(5, metric.getMaximum());
    List<Integer> hist = metric.getHistory();
    Assert.assertNotNull(hist);
    Assert.assertEquals("Incorrect history size.", 15, hist.size());
    Assert.assertEquals(new Integer(0), hist.get(0));
    Assert.assertEquals(new Integer(coverage), hist.get(hist.size() - 1));

    // we print this just for interest
    System.out.println("Action coverage: " + metric.getPercentage());
    System.out.print("History: ");
    for (Integer cov : metric.getHistory())
      System.out.print(cov + ", ");
    System.out.println();

    metric.clear();
    hist = metric.getHistory();
    Assert.assertNotNull(hist);
    Assert.assertEquals("History not reset.", 1, hist.size());
    Assert.assertEquals(new Integer(0), hist.get(0));
  }
View Full Code Here

Examples of nz.ac.waikato.modeljunit.coverage.CoverageHistory

  public void run()
  {
    for (int pass=0; pass < passes; pass++) {
      Model model = new Model(new QuiDonc());
      metric = new CoverageHistory(new TransitionCoverage(), 1);
      model.addListener(metric);
      int seed = rand.nextInt();

      seeds.add(seed);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.