【发布时间】:2016-08-22 20:05:59
【问题描述】:
我如何为以下程序构建测试:
我正在为模拟组合电路编写一个单元测试框架。该框架将支持多个数字逻辑模拟器(JLS、Logisim、TKGate 等)。因此,每个支持的模拟器都应运行一次测试。
我的第一个想法是做这样的事情:
Scenario Outline: Test of valid circuit
when I run DLUnit with "testCircuit1.<type> testFile"
Then I should see "All tests (4) passed." on stdout
Examples:
| type |
| jls | # extension for JLS files
| circ | # extension for Logisim files
| v | # extension for tkgate files
Scenario Outline: Test of invalid circuit
when I run DLUnit with "brokenCircuit1.<type> testFile"
Then I should see "There were failures" on stdout
Examples:
| type |
| jls |
| circ |
| v |
# Many more tests to follow
虽然这在技术上可行,但它会导致功能代码可能难以维护:每个功能后面都有一个受支持的模拟器列表。添加对额外模拟器的支持需要在每个测试中添加相同的行。
我也可以创建jls.feature,然后使用sed自动创建logisim.feature和tkgate.feature;但是,如果 Cucumber 提供更简单的内置解决方案,我想避免这种复杂性。
【问题讨论】:
-
也许我不明白,但据我了解,对于上述每个场景,您只会拥有两次新模拟器,这对我来说似乎很好。
-
我不喜欢引用外部文件。它隐藏了决策规则。
-
上面我只列举了两个例子。我预计完成后会有 10 到 20 个场景。
-
@DaveMcNulla,您具体指的是哪些外部文件?输入数据文件(
brokenCircuit.[jls,circuit,v]和testFile)? -
@zach 这就是我所说的,文件正在运行
标签: cucumber acceptance-testing scenarios