我试图抑制我的单元测试一个FindBugs的警告:为什么不抑制此FindBugs警告?
@SuppressFBWarnings(value = "DMI_DOH",
justification = "It's sensical when declaring expectations.")
@Test
public void ctor_checksForNullArguments() {
new Expectations(Preconditions.class) {
{
Preconditions.checkNotNull("DUMMY"); // D'oh! A nonsensical invocation…
this.result = "DUMMY";
Preconditions.checkNotNull("(dummy)"); // D'oh! A nonsensical invocation…
this.result = "(dummy)";
}
};
new InfixSymbolTest.DummySymbol();
}
我只能假设,我这样做不正确的,在警告同时通过Eclipse的功能和摇篮仍报插入。帮帮我?
- JDK:1.7.0_51
- 的Eclipse:4.3.1
- FindBugs的功能为Eclipse:2.0.3
- 摇篮:1.12
- FindBugs的注释:2.0.3
- JUnit的: 4.11
- JMockit:1.12
如果您将'@ SuppressFBWarnings'移动到匿名内部类而不是测试方法上,它是否会保持沉默? – 2014-09-21 23:29:49
顺便说一句,它真的没什么意义......这会更有意义,IMO:'this.result = Preconditions.checkNotNull(“DUMMY”);' – 2014-09-21 23:31:32
@WilliamPrice - 注释不能放在任意语句之前这是所有'新Expecatations'行)。将它分配给一个局部变量并添加注解也不起作用。 – 2014-09-21 23:34:51