Mission
org.tigris.mbt is an implementation of Model-based
testing built in java. It allows you to generate test
sequences from a
finite-state machine or an extended finite-state machine. The test
sequences can be created offline, or run online
The tool itself supports no
actual modeling.
This is done in a separate tool, yEd
from yWorks,
which is available as a free
download with unrestricted functionality. But org.tigris.mbt
should work with any graphml-compatible
editor.
org.tigris.mbt runs
on any platform that is supported by java.
Download!
The tool requires Java 1.6.
Support
Visit the forums at
mbttigrisorg.freeforums.org
Running the tool
- Copy mbt.jar
and mbt.properties
to the same folder of choice.
- Open a command window, and type: 'java -jar mbt.jar -v',
and you should get something like this:
$> java -jar mbt.jar -v
org.tigris.mbt version 2.1 (revision 619)
org.tigris.mbt is open source software licensed under GPL
The software (and it's source) can be downloaded from http://mbt.tigris.org/
This package contains following software packages:
crimson-1.1.3.jar http://xml.apache.org/crimson/
commons-collections-3.2.1.jar http://jakarta.apache.org/commons/collections/
jdom-1.0.jar http://www.jdom.org/
log4j-1.2.15.jar http://logging.apache.org/log4j/
commons-cli-1.1.jar http://commons.apache.org/cli/
colt-1.2.jar http://dsd.lbl.gov/~hoschek/colt/
jung-1.7.6.jar http://jung.sourceforge.net/
bsh-2.0b4.jar http://www.beanshell.org/
commons-configuration-1.5.jar http://commons.apache.org/configuration/
commons-lang-2.4.jar http://commons.apache.org/lang/
commons-logging-1.1.1.jar http://commons.apache.org/logging/
- You can also type: 'java -jar mbt.jar help' to
investigate what mbt can
do:
$> java -jar mbt.jar help
usage: 'java -jar mbt.jar <COMMAND> [OPTION] [ARGUMENT]'
Type 'java -jar mbt.jar help <COMMAND>' to get specific help about a command.
Valid commands are:
help
online
offline
requirements
methods
merge
xml
soap
gui
source
Type 'java -jar mbt.jar -v (--version)' for version information.
Quick start guide
offline - Generate a test sequence
Let's create a test sequence from a
simple model of
www.amazon.com,
which is called
UC01.graphml.
We
want to create an offline test sequence, that is generated by random,
but we want the generation to stop when we have passed all vertices.
The command for doing this would look like this:
$> java -jar mbt.jar offline -g RANDOM -s EDGE_COVERAGE:100 -f graphs/UC01.graphml
e_init
v_BrowserStopped
e_StartBrowser
v_BrowserStarted
e_EnterBaseURL
v_BaseURL
e_SearchBook
v_SearchResult
e_ShoppingCart
v_ShoppingCart
e_SearchBook
v_SearchResult
e_ClickBook
v_BookInformation
:
:
Let's examine the command a bit closer:
offline - This is
the command of
mbt that
will make it generate an offline test sequence. The sequence is always
printed to the console, to standard output. If you want it to a file,
you can always redirect it using '>' .
$> java -jar mbt.jar offline -g RANDOM -s EDGE_COVERAGE:100 -f graphs/UC01.graphml > my_test_sequence.txt
-g RANDOM - This
tells
mbt that
the sequence should be generated in a randomized fashion. Possible
generators for generating test sequences are:
| Generator |
Description |
| A_STAR |
Will try to generate the
shortest possible test
sequence through a model.
This
is very good when trying to find the fastest path with
complete coverage in a model. The downside is that it only works
on smaller models. If used on large models, mbt
will take a lot
of CPU time, computing the shortest path.
See Wikipedia article: A*
search algorithm |
| SHORTEST_NON_OPTIMIZED |
This is a compromise
between A_STAR and RANDOM. The
algorithm works as follows:
- Choose an edge not yet visited by random.
- Select the shortest path to that edge using
Dijkstra's algorithm (See Wikipedia: Dijkstra's
algorithm)
- Walk that path, and mark all those edges as visited.
- When reaching the selected edge in step 1, start all
over, repeating steps 1->4.
The algorithm works well an very large models, and generates reasonably
short sequences.
|
| RANDOM |
This algorithm selects an
out-edge from a vertex by
random, and repeats the process in the next vertex. |
-s
EDGE_COVERAGE:100 - This gives
mbt a
stop condition. In this case, 100% coverage of all edges. It means that
whenever that
stop conditions is
evaluated to true,
mbt
will immediately halt the test sequence generation. Possible stop
conditions are:
| Stop
condition |
Description |
Value |
| STATE_COVERAGE |
The amount of vertex
coverage, in percent of the model.
|
An integer between 1 and
100.
|
REACHED_EDGE
|
Stop at designated edge. |
The name of an edge.
|
NEVER
|
Continue for ever. |
N/A
|
| REQUIREMENT_COVERAGE |
Run until a certain amount
of percentage of requirement coverage is reached. |
An integer between 1 and
100.
|
| REACHED_STATE |
Stop at designated vertex. |
The name of a vertex.
|
| TEST_DURATION |
Run the test for certain
period of time. |
The time, given in
seconds.
|
| REACHED_REQUIREMENT |
Run the test until a
specific requirement is reached. |
The name/tagid of the
requirement.
|
| TEST_LENGTH |
How long the test sequence
should be. This is
given as how many pairs of edges/vertices should be generated. One pair
gives 2 lines to the console output, one edge and one vertex. |
An integer.
|
| EDGE_COVERAGE |
The amount of edge
coverage, in percent of the model. |
An integer between 1 and
100
|
-f
graphs/UC01.graphml - This tells
mbt what
model to use. It can be one graphml file, but it can also be a folder.
requirements - Find and list all requirements
in a model
mbt
has
the capability of keeping track of requirements. What this means, is
that you have the possibility to tag your requirements into your model.
Later on, when executing tests, you will know which requirements were
tested, and if they passed or failed.
Look at the model
www.amazon.com.
The requirements are tagged in the model using the 'REQTAG' tag. The
command below, lists all requirements found in that model, and writes
them
to the console in alphabetical order:
$> java -jar mbt.jar requirements -f graphs/UC01.graphml
UC01 2.2.1
UC01 2.2.2
UC01 2.2.3
UC01 2.3
methods - Find and list vertices and edges, by name
This command
lists all vertices and edges by their names
and writes them
to the console in alphabetical order. This is practical to know when
implementing a tool which shall execute the actual tests.
$> java -jar mbt.jar methods -f graphs/UC01.graphml
e_AddBookToCart
e_ClickBook
e_EnterBaseURL
e_SearchBook
e_ShoppingCart
e_StartBrowser
e_init
v_BaseURL
v_BookInformation
v_BrowserStarted
v_BrowserStopped
v_OtherBoughtBooks
v_SearchResult
v_ShoppingCart
merge - Write a model to the standard output
When working with large and complex
models, it is usually practical
to break them down into subgraphs. To see what the actual model will
look like, you need to merge the model using this command.
$> java -jar mbt.jar merge -f graphs/UC01.graphml
<?xml version="1.0" encoding="ISO-8859-1"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns/graphml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns/graphml http://www.yworks.com/xml/schema/graphml/1.0/ygraphml.xsd"
xmlns:y="http://www.yworks.com/xml/graphml">
<key id="d0" for="node" yfiles.type="nodegraphics"/>
<key id="d1" for="edge" yfiles.type="edgegraphics"/>
<graph id="G" edgedefault="directed">
<node id="n1">
<data key="d0" >
:
:
The
output of this commands needs
to be redirected to a file. Open the file in yEd, and there, use a
Layout Algorithm do make it look good.
xml - Wrap all fancy options into one xml file
The command xml, enables you to put all command and options into on
single xml file. For instance the command:
$> java -jar mbt.jar offline -g RANDOM -s EDGE_COVERAGE:100 -f graphs/UC01.graphml
could also be expressed in a xml file as:
NOTE:
copy this file [
mbt_setup.dtd]
to the same folder as the xml file.
<?xml version="1.0"
encoding="UTF-8"?>
<!DOCTYPE MBTINIT SYSTEM "mbt_setup.dtd" >
<MBTINIT EXECUTOR="offline">
<MODEL PATH="graphs/UC01.graphml"/>
<GENERATOR TYPE="RANDOM">
<CONDITION TYPE="EDGE_COVERAGE"
VALUE="100"/>
</GENERATOR>
</MBTINIT> |
So the new command would be:
$> java -jar mbt.jar xml -f xml/offline.xml
e_init
v_BrowserStopped
e_StartBrowser
v_BrowserStarted
e_EnterBaseURL
v_BaseURL
e_SearchBook
v_SearchResult
:
:
soap - Run mbt
as a web services
The command soap, enables you run
mbt
as web services. The purpose of
running
mbt
as web services, is that other testing tools which also
understands web services, now can communicate with
mbt.
For instance, Quick Test Professional [QTP] from HP, has that
capability.
The soap command needs a xml file,
containing all information regarding the test run. In the example
below,
I'm using the same xml file from above.
$> java -jar mbt.jar soap -f xml/offline.xml
Now running as a SOAP server. For the WSDL file, see: http://myComputerName:9090/mbt-services?WSDL
Press Ctrl+C to quit
You can now open the WSDL file browsing
to: http://myComputerName:9090/mbt-services?WSDL.
Available requests are:
| Request |
Description |
Indata |
Outdata |
GetDataValue
|
Retrieves the value of a variable in the model. (Only
if
the model is EFSM, extended finite-state machine) |
The name of the variable
[String] |
The current value of that
variable [String] |
ExecAction
|
Executes an action on an object in the model. |
The action
[String] |
The outcome of the action. [String] |
| GetNextStep |
Retrieves the name of the next vertex or edge to
execute.
|
N/A
|
The name of the label of
the edge or the vertex. [String] |
GetStatistics
|
Retrieve the statistics of the run. |
N/A |
The statistics of the run.
[String] |
HasNextStep
|
Asks mbt
if there is any more edges or vertices to execute. |
N/A |
Returns true if there still
are steps to do, else false.
[String] |
Load
|
Restart mbt
with a new xml file. |
The name of the xml file. |
Returns true if the
operation was succefull, else false.
[String] |
Reload
|
Restart mbt
with the current xml file. |
N/A |
Returns true if the
operation was successful, else false.
[String] |
An example of a script in QTP,
executing a test using
mbt.
WebService("SoapServicesService").SetTOProperty
"WSDL", "http://myComputerName:9090/mbt-services?WSDL"
If ( not WebService("SoapServicesService").Reload() )Then
Reporter.ReportEvent micFail, "MBT failure", "MBT encountered an error.
See the MBT log files for information."
ExitTest
End If
Do until not WebService("SoapServicesService").HasNextStep()
action =
WebService("SoapServicesService").GetNextStep()
If len(action) > 0 Then
If not Eval( action ) Then
Reporter.ReportEvent micFail, "Script failure", "The script encountered
an error when trying to run function: " & action
ExitTest
End if
End If
Loop
Reporter.ReportEvent micDone, "MBT Statistics",
WebService("SoapServicesService").GetStatistics()
|
The script above executes within QTP,
and calls
mbt
until the stop condition is reached. The request to
GetNextStep, which
returns a string, is put into the Eval which will call the appropriate
function.
gui - Run mbt
with a graphical user interface
The command gui will launch
mbt
with a GUI.
$> java -jar mbt.jar gui
source - Generate stub code
The command source will generate source code for you. It will
use
a template, and write the code to the console. The template used in the
example below is
java.template,
which will generate a stub for you.
$> java -jar mbt.jar source -f graphs/UC01.graphml -t templates/java.template
/**
* This method implements the Edge 'e_AddBookToCart'
*/
public void e_AddBookToCart()
{
log.info( "Edge: e_AddBookToCart" );
throw new RuntimeException( "The Edge: e_AddBookToCart is not implemented yet!" );
}
/**
* This method implements the Edge 'e_ClickBook'
*/
public void e_ClickBook()
{
log.info( "Edge: e_ClickBook" );
throw new RuntimeException( "The Edge: e_ClickBook is not implemented yet!" );
}
:
:
You can make you own template. Let's
look at the java.template:
/**
* This method implements the {EDGE_VERTEX} '{LABEL}'
*/
public void {LABEL}()
{
log.info( "{EDGE_VERTEX}: {LABEL}" );
throw new RuntimeException( "The {EDGE_VERTEX}: {LABEL} is
not implemented yet!" );
}
|
The keywords which are going to
be
replaced by relevant data are:
| Keyword |
Replaced
by |
| {EDGE_VERTEX} |
Either the word Vertex or
Edge.
|
{LABEL}
|
The name of the edge or
the vertex.
|
Documentation
Manual
Documentation is here
.
Demo and examples
Demo
An example of a model that
depicts a demo of the
www.amazon.com
site. It uses the Extended Finite-State machine notation. Which means,
that in this model,
mbt
keeps track of how many books the user has put in the shopping cart
during the test.
Go to the demo.
Examples
Samples of simple models are can be
found
here
. To open the models in a graph editor, please go to
yEd
of
yWorks
, and get their graph editor.
Go to the examples.
How to's
A collection of
how to
.
FAQ
A collection of
Frequently Asked Questions
.
Related resource
Other