Model-Based Testing - Testing Experience
Model-Based Testing - Testing Experience
Model-Based Testing - Testing Experience
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
functionality. The Login_SM_oracle_state is the oracle method<br />
generated from Login_SM through the SM2Oracle transformation.<br />
Figure 3 shows the JUnit code automatically generated through<br />
the Test2Code transformation. It includes two methods: Login_<br />
testDP (to get the test data) and Login_test (the test case). This<br />
method uses the oracle method to obtain the expected result.<br />
MATE framework<br />
The only requirement to apply the MATE methodology is the<br />
availability of tools that allow model edition, transformation and<br />
visualization. Several commercial and free UML modeling tools<br />
have improved editors to generate all the required models. The<br />
selected modeling tool must allow describing UML models and<br />
applying UML profiles, as well as to export and import XMI files<br />
following the UML meta-model, from which these models are<br />
built. Examples in this article are depicted using IBM Rational<br />
Software Architect.<br />
Furthermore, core of the MATE methodology is model transformation,<br />
which MATE supports by means of the framework described<br />
in Figure 4. Transformations are implemented at these levels:<br />
▪ Scenario to test scenario: The input for this model-to-model<br />
transformation is a scenario described with UML sequence<br />
diagrams. It produces a test model composed of a class diagram<br />
representing the test architecture (UTP test architecture)<br />
and a sequence diagram representing the test behavior<br />
(U2TP test behavior). The involved objects correspond to instances<br />
of the class diagram. This transformation is implemented<br />
using a QVT transformation and is represented as<br />
Scenario2Test in Figure 4. The test model obtained conforms<br />
to the UML <strong>Testing</strong> Profile. More information about this<br />
transformation can be found in [9].<br />
▪ Test scenario to test code: This model-to-text transformation<br />
takes the test scenario as input and produces as output some<br />
Figure 4<br />
www.testingexperience.com<br />
JUnit executable test code to test the system. This transformation<br />
is implemented using a MOF2text transformation<br />
and is represented as Test2Code in Figure 4. More information<br />
about this transformation can be found in [10].<br />
▪ State machine to oracle method: UML state machines are<br />
used to describe the test oracle; first, the state machine is<br />
augmented with specific information for testing using the<br />
Oracle Test Profile. Then, the model-to-text transformation<br />
translates the UML state machine (with the profile applied)<br />
into a method in the same language in which the application<br />
is developed; finally this method calculates the expected<br />
result. This transformation is implemented using MOF2text<br />
transformation and is represented as SM2Oracle in Figure 4.<br />
Conclusions<br />
MATE helps the tester in test case automation by using UML models<br />
that describe the system under test. The test model and its<br />
corresponding test code are derived following a model-driven<br />
approach. The result is a complete suite of executable test cases<br />
with the following information:<br />
▪ Parameterized input test data: The tester stores the input<br />
test data in the dataPool, and the test case automatically retrieves<br />
it. The operation in the dataPool returns all the input<br />
data for that test case, and the test case is executed for each<br />
set of inputs.<br />
▪ Automated calculus of the expected result: Two methods are<br />
obtained from an UML state machine: one to calculate the<br />
expected result, and another to get the expected result.<br />
▪ Test case procedure: The test case procedure is automatically<br />
generated from the sequence diagram representing<br />
the functionality under test, and it uses the information<br />
about the test input and the expected result. The test case<br />
procedure focuses on functional testing. Then, the interaction<br />
between the system and the actors is tested. As a result,<br />
the JUnit generated method recovers the test input from the<br />
dataPool; this method calls the operations to test in the SUT<br />
with the test input, uses the oracle methods<br />
to calculate the expected result, and finally<br />
validates the presence or absence of errors<br />
by means of one or more assert XUnit statements.<br />
References<br />
1. Dalal, S.R., et al. <strong>Model</strong>-based testing in<br />
practice. in International Conference on<br />
Software Engineering. 1999: IEEE.<br />
2. Dias Neto, A.C., et al. A survey on modelbased<br />
testing approaches: a systematic<br />
review. in Workshop on Empirical Assessment<br />
of Software Engineering Languages<br />
and Technologies. 2007: ACM.<br />
3. Prasanna, M., et al., A survey on automatic<br />
test case generation. Academic<br />
Open Internet Journal, 2005. 15: p. 1-5.<br />
The Magazine for Professional Testers<br />
31