'Sonarqube squid:S2699 if jsonPath validation
I have implemented controller test (using spring web testing framework).
mvc.perform(MockMvcRequestBuilders.post("/calendar").contentType(V1_0)
.content(toJSON(createCalendarDto(expectedCalendar))))
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(V1_0))
.andExpect(jsonPath("$.id", is(notNullValue())))
//...
.andExpect(jsonPath("$.email", is(expectedCalendar.getEmail())));
this test covers some important cases, checking json structure and field values.
Test works correctly, sonar prints a message:
Tests should include assertions. Code smell Critical squid:S2699
I could use workaround like @SuppressWarnings("squid:S2699") but I hope it can be managed in better way.
java 1.8 Sonarcube Version 6.3.1 Spring-boot 1.4.3
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
