Ale*_*rtz 4 junit unit-testing junit4
是否有JUnit4的扩展,允许将某些测试标记为"预计会失败"?
我想用一些标记标记正在开发的当前功能的测试,例如@wip.对于这些测试,我想确保它们失败.
我的验收标准:
Scenario: A successful test tagged @wip is recorded as failure
Given a successful test marked @wip
When the test is executed
Then the test is recorded as failure.
Scenario: A failing test tagged @wip is recorded as fine
Given a failing test tagged @wip
When the test is executed
Then the test is recorded as fine.
Scenario: A successful test not tagged @wip is recorded as fine
Given a successful test not tagged @wip
When the test is executed
Then the test is recorded as successful.
Scenario: A failing test not tagged with @wip is recorded as failure
Given a failing test not tagged with @wip
When the test is executed
Then the test is recorded as failure.
Run Code Online (Sandbox Code Playgroud)
简短的回答,据我所知,没有任何扩展可以做到这一点,并且在我看来,如果它存在,它将击败JUnit的整个目的.
更长的答案,红色/绿色是一种神圣的,规避它不应该成为一种习惯.如果您不小心忘记取消规避并假设所有测试都通过了怎么办?
你可以让它期待一个AssertionError或Exception.
@wip
@Test(expected=AssertionError.class)
public void wipTest() {
fail("work in progress");
}
Run Code Online (Sandbox Code Playgroud)
在IDE中为此创建快捷方式应该不会太难.当然,我假设您在源代码中使用注释标记测试.
在我看来,你所要求的是反对JUnit的目的,但我确实理解它的用途.
另一种方法是WIPRunner使用WIP注释实现a ,并以某种方式使其接受带有WIP注释的测试失败.
如果你正在与BDD框架集成,我会建议一种方法让它运行你单独标记@wip的单元测试,并在你的BDD方法中决定结果是否正常.
| 归档时间: |
|
| 查看次数: |
4942 次 |
| 最近记录: |