Spring Boot/인텔리제이

IntelliJ 테스트 관련 Live Template 생성하기

sendkite 2024. 11. 10. 23:24

 

1. Live Template 설정 

cmd + shift + a > Live Template

+ 버튼 클릭

2. Group 생성

- 테스트 목적의 live template을 생성할 의도로 Test group 생성

 

3. Live Template 생성

- + 버튼 >  Live Template 클릭하고 아래와 같이 코드릴 입력한다. 

- template text 창 아래 define 버튼을 눌러 java를 선택한다.

- 그러면 우측에 Reformat according to style과 use static import if possible 체크박스가 생성되는데 선택해준다. 

- Edit Variables를 클릭하고 아래와 같이 입력한다.

4. Live Template 사용

위 설정을 통해 다음과 같이 단축키로 뼈대 코드를 생성할 수 있다.

 

 

 

 

4. Assertions.assertj의 단언문도 Live Template로 생성

- 위에 보단 단순하게 statement만 선택해주고 edit variable 없이 만들어 준다. 

 

 

Reference 

- https://github.com/cheese10yun/IntelliJ/blob/master/nomal/live-template.md

 

IntelliJ/nomal/live-template.md at master · cheese10yun/IntelliJ

:octocat: 📄 IntelliJ 사용법. Contribute to cheese10yun/IntelliJ development by creating an account on GitHub.

github.com

- https://blog.jetbrains.com/idea/2020/09/writing-tests-with-junit-5/#ide-tip-live-templates

 

Writing Tests with JUnit 5 | The IntelliJ IDEA Blog

In this tutorial we're going to look at features of JUnit 5 that can make it easier for us to write effective and readable automated tests. All code in this tutorial can be found in this GitHub reposi

blog.jetbrains.com

 

반응형