This is a TestFlows example that demonstrates automated testing of a Super Mario Bros. game. The project includes a playable Super Mario Bros. game built with Pygame and automated tests that use a behavior model to test the game.
- Original game code: https://github.com/marblexu/PythonSuperMario
- Based on: https://github.com/justinmeister/Mario-Level-1
- Autonomous testing algorithm proposed by: https://antithesis.com/blog/sdtalk/
-
Testing Super Mario Using a Behavior Model (Part 1). Covers the game’s architecture and the setup of a comprehensive testing framework.
-
Testing Super Mario Using a Behavior Model (Part 2). Delves into the theory behind behavior models and its application in testing.
-
Testing Super Mario Using a Behavior Model Autonomously (Part 1). Demonstrates how to implement autonomous exploration described by Antithesis, covering weighted input generation, path scoring/cleaning, instrumentation tricks, and beating all four levels without manual input.
-
Testing Super Mario Using a Behavior Model Autonomously (Part 2). Combines autonomous explorer with the updated behavior model, adds engine observability, saves failed paths, and uses bidirectional testing to fix both model and game bugs.
pip3 install -r requirements.txtpython3 main.py- use
LEFT/RIGHT/DOWNkey to control player - use key
ato jump - use key
sto shoot firewall or run
- Run basic movement tests without model:
python3 tests/run.py
- Run tests using the behavior model:
python3 tests/run.py --with-model
- Play manually without and with model:
python3 tests/run.py --manual [--with-model] [--play-seconds 30]
- Run autonomous play without and with model:
python3 tests/run.py --autonomous [--with-model] [--play-seconds 30]
- Load existing paths for autonomous play:
python3 tests/run.py --autonomous --load-paths [--save-paths] [--paths-file custom_paths.json]
- Save video during play:
python3 tests/run.py --save-video