gpt4 book ai didi

testing - 在自己的文件中定义测试参数

转载 作者:行者123 更新时间:2023-11-28 21:30:03 24 4
gpt4 key购买 nike

在我的许多系统测试中,我测试了所有模式的特定功能。例如,在这个测试中,我测试了所有模式的警报功能:

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

如果我从每个测试中删除模式定义并将其移动到自己的文件中,您认为是否有效?因此,如果我的模式发生变化,我将不需要更新每个测试。

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

最佳答案

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

是的,它是:节省 fixtures在文件中是常见的做法。

除此之外,正如您所注意到的,您的测试变得更易于维护。

关于testing - 在自己的文件中定义测试参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25967091/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com