graph TD
classDef sub opacity:0
classDef note fill:#ffd, stroke:#ccb
A(Degree of automatization) --> B(from the view of test execution) --> C(Manual / Automated)
A --> D(from the view of the test design) --> E(Manually designed) --> F(Generated)
subgraph subE [" "]
E
noteE[ Test cases are designed by a test engineer based on specification]
end
subgraph subF [" "]
F
noteF[ Test cases are generated automatically from a test model or from the specification -> MBT Model Based Testing]
end
class subA,subB,subC sub
class noteA,noteB,noteC note
6. Model based testing (A)
Original material
This page is a work-in-progress, the original materials can be accessed at ik-elte-sharepoint
Please don’t forget that this link only works if you log into the university account, either into your e-mail or cloud service.
Agenda
Short agenda:
- Theory background of MBT (Model-based testing)
- FSM (Finite State Machine) models
- Editing specification models with GraphWalker Studio
- Generate simple test sequences with…
- GraphWalker Studio and
- Model >> Test >> Relax
Degree of automization
Model based testing
Conformance testing
- Given
- Specification model (white box)
- Implementation model (black box)
- Test if the implementation conforms to the specification?
- I.E. determine if the two corresponding model descriptions are equivalent
graph TD
classDef sub opacity:0
classDef note fill:#ffd, stroke:#ccb
A <--> B --> C
B --> D
subgraph subA [" "]
A
noteE[Specification model]
end
subgraph subB [" "]
B
noteF[Implementation model]
end
FSM (Formal specification model)
FSM-based conformance testing
graph TD
classDef sub opacity:0
classDef note fill:#ffd, stroke:#ccb
A(Specification: FSM white box) <--> B(Implementation: FSM Impl)
graph TD
classDef sub opacity:0
classDef note fill:#ffd, stroke:#ccb
A(Requirements) --> B(Specification FSM M) --> C(Implementation FSM M, SUT)
B --> D[ Test suite: test case 1, ..., test case n]
graph TD
classDef sub opacity:0
classDef note fill:#ffd, stroke:#ccb
A[Test suite] -->|Input| B(Implementation FSM Impl, SUT) -->|Observed output| C(Tester)
A -->|Expected output| C
C --> D{Verdict}
FSM exercise
- Explore the functionality of the given device and write a specification for it
- The device has 2 LEDs (red and green), a 2-way switch and a press button
- The 2-way switch turns the device off or on. When the device is turned on, the green LED lights up.
- The button can be used to change which LED lights; red or green.
- If no button is pressed for 7 secs the device changes the lights.
- Create FSM based on the specification
- Create state transition table
- Create state transition graph
- Design an input/output sequence to test all functionalities of the specification
Waiting for 7 seconds can be handled as special timeout input message
FSM exercise - solution graph
FSM exercise - state transition table
| Switch on | Switch off | press button | wait for 7 secs | |
|---|---|---|---|---|
| s_off | s_green/green | _ | _ | _ |
| s_green | _ | s_off/_ | s_red/red | s_red/red |
| s_red | _ | s_off/_ | s_green/green | s_green/green |
FSM exercise - solution example test sequence
| Action (input) | Desired output |
|---|---|
| switch on | green |
| wait for 7 secs | red |
| wait for 7 secs | green |
| press button | red |
| switch off | _ |
| switch on | green |
| press button | red |
| press button | green |
| switch off | _ |
Graphwalker
- Open source, free MBT tool with GUI
- Easy-to-use
- Good documentation
Working process
- Creating a model
- Write adaptation code that interacts with the SUT
- Generate tests
- Executing tests
Graphwalker Studio - Installation and start
- Fetch the docker image by running
docker pull graphwalker/studio - Run the image
docker run -ti --rm -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME/.Xauthority:/home/developer/.Xauthority --net=host --pid=host --ipc=host graphwalker/studio
Graphwalker Studio - Alternative installation and start
If the previous approach didn’t work one can do the following steps
- Download and install Java JDK
- Set
JAVA_HOMEvariable in the system env list if not set auatomatically
- Install model editor Graphwalker studio
After installation
- Click on graphwalker studio
graphwalker-studio-4.3.2.jar - Open a web browser and type
http://localhost:9090/studio.html