Package nz.ac.waikato.modeljunit.examples

Examples of nz.ac.waikato.modeljunit.examples.FSM


  }

  /** 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);
View Full Code Here


    Assert.assertEquals(new Integer(coverage), hist.get(hist.size() - 1));
  }
 
  public static void testBuildGraph()
  {
    ModelTestCase model = new ModelTestCase(new FSM());
    model.buildGraph();
    InspectableGraph graph = model.getGraph();
    // now check that the correct graph has been built.
    Assert.assertEquals(3, graph.numVertices());
    Assert.assertEquals(5, graph.numEdges());
View Full Code Here

   @param max     The value of metric.getMaximum() after buildGraph.
   *  @param expect  An array of {tr1,cov1, tr2,cov2, ..., trN,covN}
   */
  public void FsmCoverage(CoverageMetric metric, int max, int... expect)
  {
    ModelTestCase model = new ModelTestCase(new FSM());
    // remove old coverage listeners
    model.removeAllCoverageMetrics();
    model.addCoverageMetric(metric);
    //    System.out.println("Testing "+metric.getName());
    Assert.assertEquals(0, metric.getCoverage());
View Full Code Here

  }

  /** This tests a random walk, plus ActionCoverage metric with history.*/
  public static void testRandomWalk()
  {
    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 =
View Full Code Here

   @param max     The value of metric.getMaximum() after buildGraph.
   *  @param expect  An array of {tr1,cov1, tr2,cov2, ..., trN,covN}
   */
  public void FsmCoverage(CoverageMetric metric, int max, int... expect)
  {
    RandomTester tester = new RandomTester(new FSM());
    tester.addListener(metric);
    //    System.out.println("Testing "+metric.getName());
    Assert.assertEquals(0, metric.getCoverage());
    if (metric.getMaximum() != -1) {
      Assert.assertEquals(max, metric.getMaximum()); // should be correct or -1
View Full Code Here

        new int[] {1,0, 2,1, 3,2, 200,9});
  }
 
  public void testPrintCoverage()
  {
    RandomTester tester = new RandomTester(new FSM());
    tester.addListener("transition coverage");
    tester.addCoverageMetric(new ActionCoverage());
    tester.buildGraph();
    tester.generate(100);
    StringWriter out = new StringWriter();
View Full Code Here

public class GreedyTesterTest extends TestCase
{
  /** 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));
View Full Code Here

  }

  /** Test the effect of reset probability. */
  public static void testResetHigh()
  {
    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);
View Full Code Here

public class AllRoundTesterTest extends TestCase
{
  /** 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));
View Full Code Here

public class GraphListenerTest
{
  @Test
  public void testBuildGraph()
  {
    Model model = new Model(new FSM());
    GraphListener listen = (GraphListener) model.addListener("graph");
    checkGraph(model, listen, false);
  }
View Full Code Here

TOP

Related Classes of nz.ac.waikato.modeljunit.examples.FSM

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.