Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tasdemirbahadir/638dfdf41904cc10c59353e8300dcb15 to your computer and use it in GitHub Desktop.
Save tasdemirbahadir/638dfdf41904cc10c59353e8300dcb15 to your computer and use it in GitHub Desktop.
Sample JUnit 5 test for quality measurement project
@ExtendWith(SpringExtension.class)
@WebMvcTest(TestController.class)
class TestControllerTest {
@Autowired
private MockMvc mockMvc;
@Test
void it_should_get_test_message() throws Exception {
//Given
//When
var result = mockMvc.perform(get("/test"));
//Then
result.andExpect(status().isOk())
.andExpect(jsonPath("$").value("Hello Sonar!"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment