False positive - tests must include statements - S2699
We have a lot of code (not all) reporting an issue that does not have an assert, but exists in the test method.
Example code that gets the violation:
@Test
public void successfullValidation() throws ErrorInfo_Exception {
AgencyInfoServiceResponse agencyResponse = new AgencyInfoServiceResponse();
AgencyInfoServiceResponseHeader header = new AgencyInfoServiceResponseHeader();
header.setCmdStatus("Success");
header.setCmdType("response");
agencyResponse.setAgencyInfoServiceResponseHeader(header);
assertTrue(validator.validate(agencyResponse));
}
But if I pull the validator into a variable and assertTrue into a variable, then the violation goes away. Import assertTrue:import static org.junit.Assert.assertTrue;
I am using SonarQube 6.4.0.25310 with SonarJava 4.10.0.10260.
Why does he say that I have no statements?
+3
source to share
No one has answered this question yet
Check out similar questions: