0

In many of my system tests I test a particular functionality for all modes. For example, in this test I test the alarm functionality for all modes:

modes = ("start","stop","restart","stage1","stage2")
max_alarm_time = 10

# test alarm for all modes
def test_alarm():
    for m in modes:
       target.set_mode(m)
       assert target.alarm() < max_alarm_time

Is it valid in your opinion if I remove the definition of modes from each test and move it into its own file? Therefore should my modes change I won't need to update every test.

import test_parameters
max_alarm_time = 10

# test alarm for all modes
def test_alarm():
    for m in test_parameters.modes:
       target.set_mode(m)
       assert target.alarm() < max_alarm_time
Baz
  • 12,713
  • 38
  • 145
  • 268

1 Answers1

1

Is it valid in your opinion if I remove the definition of modes from each test and move it into its own file?

Yes it is: saving fixtures in files is common practice.

Beside that, as you have noticed, your test became more maintainable.

taringamberini
  • 2,719
  • 21
  • 29