Привет я получаю ошибку findbugs в моем тесте JUNIT
Вот мой тест.
public class MyTest {
@Autowired
private MyService myService;
@Test
public void serviceShouldSayMine() {
Assert.assertEquals(this.myService.getText(), "Mine");
}
}
мой фильтр поиска ошибок.
<findbugsfilter>
<match>
<class name="~.*Test"/>
<or>
<field name="~.*Dao"/>
<field name="~.*Service"/>
<field name="~.*TestUtils"/>
</or>
<bug pattern="UWF_UNWRITTEN_FIELD" type="UWF_UNWRITTEN_FIELD"/>
</match>
<match>
<class name="~.*Test"/>
<or>
<field name="~.*Dao"/>
<field name="~.*Service"/>
<field name="~.*TestUtils"/>
</or>
<bug pattern="NP_UNWRITTEN_FIELD" type="NP_UNWRITTEN_FIELD"/>
</match>
</findbugsfilter>
Я добавил фильтр к затмению, но все еще получаю ошибку. Чтение неписаного поля myService, когда я нажимаю на него, оно говорит
Pattern id: UWF_UNWRITTEN_FIELD, type: UwF, category: CORRECTNESS
This field is never written. All reads of it will return the default value.
Check for errors (should it have been initialized?), or remove it if it is useless.
, а также
Pattern id: NP_UNWRITTEN_FIELD, type: NP, category: CORRECTNESS
The program is dereferencing a field that does not seem to ever have a non-null
value written to it. Dereferencing this value will generate a null pointer exception.
Что не так с моим фильтром,
Моя цель - отфильтровать все классы
a.) Окончание с помощью* Test или * TestCase
b.) Метод внутри класса, заканчивающийся * Service или * Dao