Here's how our tests are setup:
- Tests are grouped in subdirectories
- Each directory/filename is prefixed with a number between 100-999, typically incremented by 10. This allows us to insert new tests into the stream of sequential tests
- Tests start at 100, but configuration setup tests start at 010.
- Tests are tagged according to the directory, and directory/file
This is very easy to understand/use, especially when you get 1000s of steps/scenarios and complex tests in your setup.
- 100-Basic Emulator Tests/
- /010-Website Create TEST100 Device.feature
- /100-Emulator Test Device Registers.feature
- 110-Basic Med Configuration/
- /010-Website Create TEST110 Device.feature
What does the script do?
- Lines up your "I" in a perfect column
- Each Scenario:, Given, When, Then, And are right-justified to column 15
- Remaining line is left justified at column 16
- The Feature: top line is replaced with the directory name (the directory name defines the group of tests)
- Tags are inserted at the top as follows:
- @### -- The 3-digit prefix of the directory
- @###-### -- The 3-digit prefix of the directory plus the 3-digit prefix of the individual test
@100 @100-010 Feature: 100-Basic Emulator Tests/010-Website Create TEST100 Device Scenario: Admin verifies we are running in the TEST environment Given I am on the / page Then I will see -test ...
This is an example for using behave (Python based), but applies to any platform.
- To run all tests in directory 100:
- To run just test 100 in directory 100, run:
- Say you the first file in directory 100 is a setup function you want to run before your individual test:
- This effectively runs the first file of the 100's (which is your "setup" scenario), then runs all tests in 140. So, you're skipping all the tests between 100-140
- Now, say you have a specific test in 140 that's failing:
- Or you want to re-initialize everything before running this one test: