Int*_*eep 2 java testing junit code-coverage junit4
我无法涵盖下一个方法:
protected void dealDamage(int damage, String damageType) {
this.setDamageDealt(damage);
this.setDamageDealtType(damageType);
}
Run Code Online (Sandbox Code Playgroud)
我的测试看起来像这样:
@Test
@Parameters({"30, physical"})
public void dealDamage(int damage, String damageType) throws Exception {
this.creature.setDamageDealt(damage);
this.creature.setDamageDealtType(damageType);
assertEquals(this.creature.getDamageDealt(), 30);
assertEquals(this.creature.getDamageDealtType(), "physical");
}
Run Code Online (Sandbox Code Playgroud)
测试返回成功,但方法根本没有涉及.哪里可能是我的错?我错过了什么吗?