본문 바로가기
프로그래밍/기타등등

TDD를 연습해 보았다...

by yonmoyonmo 2021. 4. 14.

*주의* TDD 연습을 해 보고 느낀 점을 적은 글입니다. TDD에 대한 정보는 하나도 엄서요~~~~

Red...Green.....Refactor.....

중요한 것은 마음가짐... 하마터면 주객전도 될 뻔 했다....
스프링 부트에서 어노테이션으로 엄청 지원해줘서 그거만 보다가 TDD의 핵심 철학을 놓칠뻔 했다...

중요한 것은 바로바로 테스트 코드를 먼저 쓰고 개발을 해 나가면서 클린 코드와 코드에 대한 자신감 등등 부수적인 효과를 얻는 것이다! 그리고 그걸 돕는 것이 바로바로 스프링부트의 테스트 도구들이다! 그러니 올바른 테스트 코드를 쓸 수만 있다면 도구는 그 때 그 때 찾아서 스면 된다!(그러려면 무엇무엇 있는지 알긴 해야함)

그렇다면 올바른 테스트 코드는 무엇인가??!!

  • Fast ( 빠름 )
  • independent ( 독립됨 )
  • Repeatable ( 반복 가능 )
  • Self-validating ( 테스트가 성패를 판단하기 위해 다른 무엇을 찾아보게 하면 안된다 )
  • Timely ( 적시에(테스트 코드 먼저 쓰기) )

라고 한다!

그리고 진짜 명명백백히 결과가 뻔하고 간단한 것들은 굳이 테스트 코드를 쓸 필요가 없는 것 같다. 이미 자신감 넘치기 때문이다. 그렇지만 맨날 쓰던 코드라도 조금이라도 쫄리면 테스트 코드를 먼저 조지는 것이 좋은 것 같다. 코드는 자신감이다!!!!!

아무튼 자기가 짠 로직 등에 대한 강한 확신이 들어야지 리펙토링도 가능하지 않을까? 이거 고쳤다가 안되는거 아니야? 하면 리펙토링이 가능할까? 그래서 TDD로 코드 자신감 상승 -> 그러다 보니 클린코드 -> 협업능률 상승 -> 프로젝트 작업 효율 최강 이래서 요즘은 TDD가 대세인갑다. 이제이제 매일매일 작업 할 때마다 TDD해야지.

연습한 흔적 : github.com/yonmoyonmo/tdd-practice

 

yonmoyonmo/tdd-practice

let's practice TDD w/ Junit. Contribute to yonmoyonmo/tdd-practice development by creating an account on GitHub.

github.com

참고한 다른 분들의 글 :

https://joont92.github.io/spring/spring-boot-test/

 

[spring] spring boot test

https://meetup.toast.com/posts/124 spring boot test 모듈은 아래의 2개가 존재함 spring-boot-test spring-boot-test-autoconfigure 대부분 spring-boot-starter-test로 충분함(위의 2개를 다 포함하고 있나?) @SpringBootTest @ContextConf

joont92.github.io

https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-testing

 

Spring Boot Features

Graceful shutdown is supported with all four embedded web servers (Jetty, Reactor Netty, Tomcat, and Undertow) and with both reactive and Servlet-based web applications. It occurs as part of closing the application context and is performed in the earliest

docs.spring.io

https://spring.io/guides/gs/testing-web/

 

Testing the Web Layer

this guide is designed to get you productive as quickly as possible and using the latest Spring project releases and techniques as recommended by the Spring team

spring.io

https://brunch.co.kr/@springboot/207

 

스프링부트 테스트(1)

스프링 부트 Unit Test 및 Integration Test | 테스트코드를 작성하는 일은 정말 중요하다. 하지만, 필자에게 아직도 너무 어려운 일이 바로 테스트 코드를 작성하는 일이다. TDD 를 잘하는 개발자는 필

brunch.co.kr

https://goddaehee.tistory.com/212

 

[스프링부트 (10)] SpringBoot Test(3) - 단위 테스트(@WebMvcTest, @DataJpaTest, @RestClientTest 등)

[스프링부트 (10)] SpringBoot Test(3) - 단위 테스트(@WebMvcTest, @DataJpaTest, @RestClientTest 등) 안녕하세요. 갓대희 입니다. 이번 포스팅은 [ 스프링 부트 단위 테스트 하기 (@WebMvcTest, @Dat..

goddaehee.tistory.com

https://joont92.github.io/spring/spring-boot-test/

 

[spring] spring boot test

https://meetup.toast.com/posts/124 spring boot test 모듈은 아래의 2개가 존재함 spring-boot-test spring-boot-test-autoconfigure 대부분 spring-boot-starter-test로 충분함(위의 2개를 다 포함하고 있나?) @SpringBootTest @ContextConf

joont92.github.io

hackernoon.com/test-f-i-r-s-t-65e42f3adc17

댓글