Ensure that you have the following 3 games dumped and that they match these SHA1 hashes:
- Pokémon Emerald, English (
f3ae088181bf583e55daf962a92bb46f4f1d07b7
) - Pokémon Ruby, English, Rev. 2 (
5b64eacf892920518db4ec664e62a086dd5f5bc8
) - Pokémon FireRed, English, Rev. 1 (
dd5945db9b930750cb39d00c84da8571feebf417
)
From the repository root, run one of the following commands:
# Runs all tests
python -m unittest discover -s tests
# Runs only tests from a particular file:
python -m unittest tests.test_mode_spin
# Runs a single test
python -m unittest tests.test_mode_spin.TestModeSpin.test_it_catches_shinies
Check out one of the existing test files for inspiration, but here are some things to be aware of:
- A file with test cases must match the naming pattern
test_*.py
. - Inside that file, create a class that inherits from
BotTestCase
. - This class can have an arbitrary amount of test methods, but each
of them must have a name that starts with
test_
. - Make sure that any imports from
utility.py
are done withfrom tests.utility import ...
instead offrom utility import ...
. - Any imports from the
modules
directory need to be done inside the test method and not outside. This is to ensure that nothing is loaded before the test runner can set up its mocks. - For tests that require soft resets, the save game must be included
in the state file. That is not the case for regular save states
that the bot creates. To create such a save state, run the bot in
debug mode and then use the
Debug
menu and selectCreate state with save game
.
from tests.utility import BotTestCase, with_save_state, with_frame_timeout
class TestWhatever(BotTestCase):
@with_save_state("emerald/some_state.ss1")
@with_frame_timeout(1000)
def test_something(self): ...
@with_save_state(["emerald/some_state.ss1", "ruby/some_state.ss1"])
@with_frame_timeout(1500)
def test_something_else(self):
# This will run twice -- once with each state listed in the
# @with_save_state decorator.
...