Skip to content

Run Single File Tests

The command line mpf test can run single file tests or doc pages.

You can create a text file which contains the main config, shows and modes of your test machine. Then at the bottom you can create some test assertions.

The structure look like this:

# your machine-wide config here. That is what is normally in config/config.yaml.

# you can have a few modes
##! mode: some_mode
# mode config here

# you can have a few modes
##! mode: another_mode
# mode config here

# additionally you can have separate shows
##! show: some_show
# show here

# now you can add a test
##! test
#! start_game
# run the machine for 1 virtual second
#! advance_time_and_run 1
# post an event
#! post some_event

All test assertions are defined in MpfDocTestCase. Just remove the command_ prefix and you are good to go.

Something missing or wrong? You can fix it!

This website is edited by people like you! Is something wrong or missing? Is something out of date, or can you explain it better?

Please help us! You can fix it yourself and be an official "open source" contributor!

It's easy! See our Beginner's guide to editing the docs.

Page navigation via the keyboard: < >

You can navigate this site via the keyboard. There are two modes:

General navigation, when search is not focused:

  • F , S , / : open search dialog
  • P , , : go to previous page
  • N , . : go to next page

While using the search function:

  • Down , Up : select next / previous result
  • Esc , Tab : close search
  • Enter : go to highlighted page in the results