1. Confidence in your code — 코드에 대한 자신감
writing test is not weakness of code or implies that the code underneath is bad
we continue in working on our code we can say with confidence
everything still works the way that it should.
— 테스트 코드를 쓰는 것은 코드의 약점을 드러내는 것이 아니다.
— 코드에 대한 자신감을 심는 것이다.
→ 코드가 잘 작동한다는 것을 증명한다.
2. Documentation for developers — 개발자들과 문서화되어 공유할 수 있는 코드
Writing a test can also be treated as documentation of code.
After a few weeks no touching a certain part of your codebase and then return in to it
It*'s greate to check out the tests and verify the expected outcome of specific code should actually be.*
— 테스트 코드의 작성을 문서화로도 볼 수 있다.
— 코드를 몇주 후에 다시 봤을 때, 코드의 목적성을 확인 할 수 있다.
3. Refactoring gets easy — 리팩토링이 쉬워진다
Tests give us confidence is not accidentally breaking working code.
One thing developers love besides creating new code, is refactoring code.
Refactoring can alaways bae the risk of accidentally altering the outcome of a function.
→ so if we hava a automated test, tell me the results are still the same as before
— Test는 작업 코드가 망가지지 않을 것이라는 확신을 준다.
— 개발자가 코드를 만들 때,
⇒ 리팩토링시에 변화에 의해 감수하게 되는 위험을 테스트 할 수 있게 해준다.
sometimes look at functions and have no idea to test them.
Test should be simple and no longer or event more complex.
Simplify the tested function
→ split up some code and so on.
— 가끔은 function에서 무엇을 테스트 해야 할지 감이 오지 않을 때가 있다.
— 테스트는 간단해야하고, 복잡한 이벤트가 없어야 한다.
→ function을 쪼개게 된다.