简体   繁体   English

Junit 4测试范围

[英]Junit 4 Testing coverage

I am unable to cover next method: 我无法涵盖下一个方法:

protected void dealDamage(int damage, String damageType) {
    this.setDamageDealt(damage);
    this.setDamageDealtType(damageType);
}

My test looks like this: 我的测试看起来像这样:

@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");
}

Test return success, but method is not covered at all. 测试返回成功,但是方法完全没有涵盖。 Where could be my mistake? 我的错误可能在哪里? Do I miss something? 我想念什么吗?

问题是您没有调用要进行单元测试的方法,即dealDamage()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM