In our previous articles we have already discussed about the finite state machines and about how we can take advantage from this utility of the Graphwalker API. It is based on nodes and vertices which are connected to each other to become a graph and forming a test case to make your job easier and clear.
Moreover Graphwalker provides additional possibilities to make the job be in a batter quality. The edges could be extended by expressions and these can modify the further way of test run. Excluding the label the edge can contain two other elements. The first one called guard and another one is action. These have a unique order like this: Label [Guard] / Action1; Action2;

The guards are logical expressions which define the certain path of execution depending on logical value of the result. They are always after the label of the edge within brackets like [conditional_variable == true]. If it evaluates to true the edge will be executed otherwise will not. The advantage of this kind of decision-making is that can be handled without any interaction with code in the test. However the developers make it possible to read or change the value of the guard in the program code to help the navigation.

getMbt().getCurrentEdge().setGuardKey("[nameOfGuard == true]")

The actions are also very important elements of the diagram because they can modify the values of the variables without interacting of the test code. These action is any Java code will be executed by an internal BeanShell interpreter. For instance they can help to modify the guards, navigating the tests to the correct way. The actions do not require brackets like the guards but they must be separated with a “/” from the label or guard and the number of actions in an edge is not limited. This is presented on the picture above. These values also can be handled in test code to make decisions, calculate other parameters or do something on webpage.


As a result of using guards and actions the program code is simplified, and it is very beneficial because you do not have to get all the parameters and variable from the graph to deal with them, but the Graphwalker can handle all the thing on its own. The tester can focus to more important problems which affect the test framework. Moreover the framework gives possibility to work with them yourself if it is needed.

Posted By Árpád Farkas

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>