MODEL BASED TESTING


“Model-based testing is 
software testing 
in which test cases are derived 
in whole or in part 
from a model 
that describes some 
(usually functional) 
aspects of the 
system under test (SUT).” 
-Wikipedia

WARNING !



<braindump>

WHAT IS A MODEL ?



GRAPHS



FINITE STATE MACHINES



FINITE STATE MACHINE


WHY TEST WITH MODELS ?



A model is a description of a system’s behavior. 

Models are simpler than the systems they describe.

Models help us understand and predict the system’s behavior. 

WHY TEST WITH MODELS ?






WHY TEST WITH MODELS ?



Test cases generated from model

Easier to maintain

Run different types of tests from the same model

HOW DO I GET STARTED ?

0. GET YOUR TOOLS




yEd (free)

Graphwalker (free)


1. DESIGN



export as .graphml


2. GENERATE SKELETON


 #!/bin/bash

GWJAR=../lib/graphwalker-2.6.3-SNAPSHOT.jar
MODEL=../model/simpleSmart.graphml
TEMPLATE=../template/ModelAPI.template

java -jar $GWJAR source -f $MODEL -t $TEMPLATE

3. IMPLEMENT THE TESTS


/**
* This method implements the Edge 'e_LogIn'
*/
@Test
public void e_LogIn() {
	...code to log in...
}

/**
* This method implements the Vertex 'v_LoggedIn'
*/
public void v_LoggedIn() {
	...code that validates we are logged in...
}

4. CHOOSE HOW TO RUN THE TEST


// Smoke test

modelhandler.add("Login", new Login(file, true, new A_StarPathGenerator(new ReachedVertex("v_SomeVertex")), false));

// Functional test

modelhandler.add("Login", new Login(file, true, new RandomPathGenerator(new EdgeCoverage(1.0)), false));

// Stability test
modelhandler.add("Login", new login(file, true, new RandomPathGenerator(new TimeDuration(10*3600)), false));

5. RINSE & REPEAT






</braindump>

Made with Slides.com