Spring:テストコード
6919 ワード
テストコードの概要

ユニットテストのメリット
HelloController Test Code
@RestController
public class HelloController {
@GetMapping("/hello")
public String hello() {
return "hello";
}
}
@RestController@RunWith(SpringRunner.class)
@WebMvcTest(controllers = HelloController.class,
excludeFilters = {
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = SecurityConfig.class)
}
)
public class HelloControllerTest {
@Autowired
private MockMvc mvc;
...
@WithMockUser(roles="USER")
@Test
public void hello가_리턴된다() throws Exception {
String hello = "hello";
mvc.perform(get("/hello"))
.andExpect(status().isOk())
.andExpect(content().string(hello));
}
-スプリングガイドテストとjunit間のコネクタロール
ブラウザ結果の確認

ハブ実習コード
Reference
この問題について(Spring:テストコード), 我々は、より多くの情報をここで見つけました https://velog.io/@donsco/Spring-테스트-코드テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol