Programming45 AfterEach 어노테이션 사용법 TestCase는 작성한 각각의 테스트들을 class 단위로 한 번에 테스트 할 수 있다는 장점이 있다. 그러나, 테스트의 순서는 보장되지 않아 한 번에 돌리는 경우 무작위로 테스트 된다는 단점도 공존한다.🤨 (따라서 순서에 의존적으로 설계하면 안됨!) 그래서 테스트가 하나 끝나면 clear해줘야 하는데, 그럴 때 사용하는 것이 바로 AfterEach 어노테이션이다. @AfterEach (AfterEach 어노테이션) : 해당 어노테이션을 사용하면 각각의 테스트 메소드가 실행된 후에 정리 작업이나 공통적인 후처리 작업을 수행할 수 있다. import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import static org.j.. 2024. 1. 4. 테스트 케이스 - Assertions 스프링부트 프로젝트를 하면서 테스트 케이스를 작성할 때 사용하는 메서드 중의 하나인 Assertions의 두 가지 버전에 대해 설명하고자 한다. ☝️ Assertions (org.junit.jupiter.api 패키지 제공) : 테스트 케이스를 작성할 때, JUnit과 함께 자주 사용되는 것 중 하나인 Assertion 테스트 결과를 검증하고 예상 값과 실제 값이 일치하는지 확인하는 데 사용된다. import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; public class MyServiceTest { @Test public void testAddition() { MyService myService = new.. 2024. 1. 4. Getter & Setter Getter & Setter 📝 예제코드 static class MyClass { private String className; public String getClassName() { return className; } public void setClassName(String className) { this.className = className; } } 예제를 보면 인텔리제이에서 ‘MyClass’라는 클래스를 만들고 Alt + Insert를 클릭하면 Getter and Setter를 선택할 수 있다. Getter and Setter를 선택하면 상단의 소스 코드처럼 Get과 Set이 자동으로 세팅 된다. 이걸 자바 빈(Bean) 규약이라고 하는데, className 같은 경우 private이기 때문에 외.. 2023. 12. 19. ResponseBody 어노테이션 사용법 @ResponseBody (ResponseBody 어노테이션):HTTP에서 BODY 쪽에 return 데이터를 직접 넣어주겠다는 뜻임 ☝ 예제@GetMapping("hello-string")@ResponseBodypublic String helloString(@RequestParam("name") String name) { return "hello " + name; } 만약 @RequestParam(”name”) 여기 부분에 ‘stone’을 넣는다면 return 값은 “hello stone" 이 될 것이다.그래서 템플릿 엔진과 다르게 해당 문자열을 직접 뷰에 보낸다는 의미이다.(↔템플릿은 뷰 리졸버(View Resolver)에게 ‘나랑 맞는 애를 찾아줘’하고 요청을 던져서 화면에 출력함) ✌ 예제@.. 2023. 12. 19. 스프링부트 SecureRandom 예제 관리자페이지 생성 후 관리자 등록 시, 임의의 비밀번호를 생성해서 발급해주려 한다. 임의의 난수를 만드는 함수로는 Random, SecureRandom이 있는데 그중에서도 SecureRandom이 암호적으로 더 강력한 난수를 만들어주는 클래스라고 하기에 사용해 보았다. ✨ SecureRandom 관련 내용은 하단 링크 참조 https://docs.oracle.com/javase/8/docs/api/java/security/SecureRandom.html SecureRandom (Java Platform SE 8 ) This class provides a cryptographically strong random number generator (RNG). A cryptographically strong ra.. 2023. 11. 20. [Git] Another git process seems to be running in this repository : 에러해결 현상 commit 을 하려던 중 잘되던 git이 해당 에러를 내뱉었다. Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make sure all processes are terminated then try again. If it still fails, a git process may have crashed in this repository earlier: remove the file manually to continue. 해결 문제가 생긴 .git 폴더에가서 index.lock 파일 삭제함 커맨드로 진행하는 경우 해당 git 경로로 들어가서 rm -f ./.git/.. 2023. 8. 11. 이전 1 2 3 4 5 6 7 8 다음