Testing & Debugging
Unit Tests
Unit tests are located in the tests/ directory. They are designed to ensure the correctness of the codebase and should be run regularly during development.
Please ensure that you have set up the test environment as described in the Setting Up Your Environment section before running the tests.
Running Tests
To run the tests, you can run the bash script (which we called it Touhou Bot Test Tool):
./tests/test.shIt will automatically discover and run all tests in the tests/ directory, and generate a coverage report.
For more usage, you can run the following command:
./tests/test.sh helpWriting Tests
When writing tests, please follow these guidelines:
Place your test files in the
tests/directory.Use descriptive names for your test files and functions.
Use the
pytestframework for writing tests.
Debug Tools
In utils/, we provide some debugging tools to help you debug the codebase. These tools can be used to capture screenshots, detect game states, and more.
Screenshot Capture Tool
screenshot.py is a tool to capture screenshots of the game window. It can be used to capture screenshots at specified intervals and save them to the screenshots/ directory. Notice that the frequency is setting to 1 frame per second.
python utils/screenshot.py --ver=08 --time=60 # Capture screenshots for 60 seconds for version 08Heatmap Visualization Tool
heatmap_visualizer.py is a tool to visualize the heatmap of the game screen to test the bullet detection module. It reads the screenshots from the screenshots/ directory and generates heatmaps based on the detected bullets. The heatmap will be saved to the heatmaps/ directory.
python utils/heatmap_visualizer.py --ver=08 # Visualize the heatmap for version 08Character Visualization Tool
character_visualizer.py is a tool to visualize the detection results of characters to test the character detection module. Similarly, it reads the screenshots from the screenshots/ directory and saves the results to the character_detections/ directory.
Last updated
