
Java/Spring 주니어 개발자를 위한 오답노트
김우근
스프링이랑 JPA를 조금 다룰 줄 알게 된 당신, 앞으로 성장하기 위해 무엇을 어떻게 공부해야 할까요? 혹시 설계 공부를 해보겠다고 디자인 패턴을 공부하면서 패턴들을 무작정 암기하고 계시진 않으신가요? 제가 도와드릴게요!
초급
Java, Spring, 객체지향
Learn how to add tests to Spring! Then, learn how to change the Spring design to make testing more natural.
How to put tests in Spring
Concepts needed for testing
How to do a natural test
How to test without Mockito
Dependency and Testability
Hexagonal Architecture and Design
Developing project design
Let me explain the essence of the test!
Because I thought that in order to give you the right opinion about testing, it ultimately has to end with architecture.
Learn the basic concepts of testing and how to integrate tests into Spring. Furthermore, learn how to change the Spring design to enable natural testing.
The test
Why is it needed?
About the test
Basic Concepts
In spring
Putting the test
method
Spring design
Evolving
method
Clean
Architecture
Hexagonal
Architecture
My friends at other companies are steadily adding tests to keep up with the demands of the times and are growing step by step. But our company doesn't have tests. I don't want to fall behind. I have the will to study. But I just can't figure out how to add test code to this legacy system .
Testing with H2 is too slow and too dependent on the DB. All tests use H2. It is burdensome to run tests, and since tests share h2 , data gets tangled, so sometimes tests pass and sometimes they fail .
Our team is not that many people, and I have never felt that anxious while deploying. The requirements change all the time. But how do you do TDD? I think testing only slows down the development speed .
If you look at the books or seminars on testing on the market, most of them just talk about the advantages of testing, how to write test code, JUnit, Mockito, and so on, and end there. The examples are simple enough to suit the taste of beginners. So when I close the book at the end, I think this.
It was confusing. JPA test using H2... well, it's good. But how can I test it if I don't have a test DB like ElasticSearch or Cassandra? In addition, the test using H2 was really slow to the point of being fatal. It was burdensome to run it several times a day. The test broke frequently, and on days when the DB table changed, I had to modify all the related tests, so it often felt like a waste of time.
Then, all my worries were solved when I started studying architecture and DDD . I know. TDD is always hot. But TDD is a really attractive but difficult methodology. If an organization that has never done TDD tries to develop with TDD because TDD is popular, will it be okay? TDD really requires a lot of prior knowledge and empathy before starting, more than you think.
So, if you want to study TDD, you shouldn't start with TDD. You should start with testing. Just like you need to know how to handle equations before you can do calculus.
If you don't feel the need for testing, then your project is not big enough yet, or you have a good enough development capability and culture to not need testing. Testing is not the answer! Many great projects were developed even in the days when there were no tests. Testing is a tool for getting good software, not a goal in itself.
It seems that you studied too much only on how to do tests . It is certainly meaningful to study how to use JUnit, how to use Mockito, and how to link h2, but that is not the essence of testing. You need to learn why you should do tests, what the goals are, and how to practice to achieve those goals.
The question about test frameworks is also the same answer as the previous question. If you are in an environment where you use Typescript
+ Nest.js
, how will you test it? You need to learn how to test it without a test framework like Mockito or H2 .
The knowledge based on this principle is knowledge that can be applied to other frameworks as well. Whether you use Nest.js, Swing UI, or Gin... I think it is knowledge that can be applied anywhere.
The final chapter will be devoted to a lecture on design . This is because I felt that design should not be left out in order to fully explain the value of testing.
At least, I haven't found any books or lectures that teach you how to add tests to Spring in Korea. Everyone uses annotations like @Mock
and @Spy
to mock and inject dependencies to write tests. But what if there is no such Mock library in an environment? Essentially, you need to know how to test without these annotations ! And you need to be able to distinguish what you need to test.
You will learn the need for testing .
Learn how to add tests to Spring without a framework .
You will discover a better way to use Spring .
You will understand how to transition from a layered architecture to a hexagonal architecture .
Orientation
Let's look at why TDD fails when it is introduced in an organization that wants to add tests. Let's look at why TDD, which I usually do, fails. Let's look at the problems that occur when you start adding tests without a proper understanding of tests.
Theory of Testing
Study basic test knowledge. Empathize with the need for testing and understand the correlation between testing and design. Understand what developers should consider when creating tests. Finally, we will look at the work of increasing testability for natural testing.
Part 1 - Applying Testing Based on Toy Project
Let's take a look at the toy project that we will use in the future. Then, we will randomly add tests to the toy project and achieve 100% coverage by adding as many tests as possible. In this process, we will use external libraries such as h2, MockMvc, and PowerMock.
Let's take a look at the final tests that were created and see what's wrong with tests that only cover regression bugs.
Directional exploration
We will look at why putting tests in our toy projects is not a good idea. We will also look at the problems with traditional layered architecture. And we will hear the speaker's opinion on how to improve it.
If you struggled to just add tests in Part 1, in Part 2, you will learn how to mock naturally without an external library like Mockito. Let's take a look at how to change the code in advance for Part 2.
Part 2 - Toy Project Structure Design Improvement
We apply the insights gained through the previous direction exploration to our toy project. In this process, we improve the design by making structural changes. And in this process, the following techniques are used.
Evolving Architecture
We will explore how to evolve architecture through the correlation between testing and design. We will see how layered architectures evolve into hexagonal architectures. We will learn how to focus developers on the domain by separating concerns.
I am currently working at Kakao, and I love making things, so I am always developing something after work. There is a saying, "A dwarf standing on the shoulders of a giant." I am just a small dwarf, but I am trying to pass on my knowledge so that I can help the giants grow. I have experience mentoring many junior developers, so I think I can help you grow.
Q. Can you tell me how to use JUnit or Mockito?
Yes, unfortunately, this course does not cover how to use JUnit and Mockito. Here are the reasons why:
Context) Each student is in a different situation. If someone has already written a few tests, their proficiency in handling libraries may vary. The library used by the company may not be JUnit or Mockito. There may be interfaces that are not provided because the version is different. For example, JUnit4 does not support @ParameterizedTest. In addition, the usage of the libraries mentioned above is not that difficult, and there are already too many good related materials. I think that you can learn how to use them sufficiently just by reading the Github README file or the official guide. Therefore, I thought that the usage was not important.
Test Design) Learning how to test using a specific function provided by a specific library means that you cannot do that test without that library. How to design tests and how to turn them into testable structures is more important than tools or frameworks. Therefore, this lecture does not focus on tools. Testing is a part of the development process. Therefore, I thought it was more important to check the points that should be considered in the context of requirements analysis, design and deployment, and maintenance.
Q. What are the differences from previous lectures ?
As you can see from the curriculum, there is some overlap with previous lectures. It is not convincing enough to explain in detail what should be done, and it is not possible to understand the context, so the lectures are organized so that you can take the relevant lectures independently. So please be sure to check the table of contents and see if there is any overlap.
To be honest, if you have properly understood the previous lectures, I don't think you need to take this lecture again. If the previous lectures were lectures that explained why the structure should be like this, you can think of this lecture as a lecture that actually deals with how to solve it at the code level.
Q. Is there anything I need to know before taking the course?
This lecture is not a lecture that teaches Spring or JPA. It is assumed that the student can handle Spring and JPA in general. In addition, it teaches how to add tests to Spring , but it focuses on how to resolve dependencies , and I don't think it is necessarily limited to a language or framework. In addition, specialized knowledge is not required :)
💾 Please check before taking the class!
Who is this course right for?
If you want to add tests to Spring
If you are confused about how to add tests to Spring
If you are confused about whether the Spring project you developed has the correct design structure
Those who tried to insert the test but failed
Those who want to put tests in NoSQL that doesn't have a test DB like H2
Need to know before starting?
You can understand Java code
Spring Basics (For those who know what Controller/Service/Repository are)
Have you used JPA?
3,456
Learners
250
Reviews
47
Answers
4.9
Rating
2
Courses
현재 카카오에서 일하고 있고, 만드는 것을 좋아해서, 퇴근 후에도 항상 무언가를 개발하고 있습니다.
"거인의 어깨 위에 선 난쟁이"라는 말이 있습니다. 저 역시 한낱 작은 난쟁이일 뿐이지만, 올라탄 거인의 성장에 도움이 될 수 있도록 지식의 대물림을 위해 노력하고 있습니다. 다수의 주니어 개발자분들을 멘토링 한 경험이 있어서 여러분의 성장을 도와줄 수 있을 거예요.
깃허브 > https://github.com/kok202
블로그 > https://kok202.tistory.com
All
25 lectures ∙ (6hr 20min)
Course Materials:
All
174 reviews
4.9
174 reviews
Reviews 2
∙
Average Rating 3.0
5
내가 인프런에서 결제한 모든 강의 통틀어서 최고의 강의라 단언한다. 책에서 베끼지 않고 머리 쥐어 뜯으며 만든 오리지널 커리큘럼 구성, 강의 마다 꽉꽉 차 있는 알맹이들, 어영부영 횡설수설 없음, 깔끔한 멘트와 문장, 적절한 속도와 명확한 발화, 테스트라는 구체화된 실천 방법을 통해 설계라는 큰 그림을 그리고, 다시 설계라는 바탕 아래 테스트를 끌어낸다. 강사님이 얼마나 고민하고 반복하고 개선하며 개발을 해오셨는지 보이지 않아도 보인다. 그걸 강의로 기가 막히게 녹여 내셨다. 인프런에서 강의 한 두개 들어본 게 아니지만 이 강의 만큼 A/S를 세련되게 한 것도 못봤다. 영상이라는 게 또 찍고나면 글처럼 쉽게 수정할 수 있는게 아니기도 하고, 강의 특성 상 항상 아름답고 한치의 실수도 없는 뭔가를 보여주고 싶은 욕구도 강할텐데 그러한 부분은 가감없이 세련되게 수정해두었다. 강사님이 실수나 "이랬으면 좋았을텐데"하는 부분에서는 화면이 회색으로 바뀌면서 음성만 나오는 구간이 있다. 이런 부분이 나오면 내가 정신차리고 듣고 있나 점검도 되고, 내 생각과 비교해 볼 수도 있고, 저런 고민을 강사님도 하시는 구나 싶기도 하고, 암튼 이런 A/S영상도 마치 짜여진 각본처럼 교육 도구로 훌륭히 역할을 하게 해두었다. 테스트를 샀는데 설계가 딸려왔다. 근데 그 설계가 테스트보다 더 비싼거였다. 이런 미친듯이 훌륭한 강의에 수강평 54개 뿐인 거 보고 빡쳐서 수강평 처음 써 본다 ㅋㅋ 내용, 목소리, 오디오, 영상, 분량.. 모든 게 응집력있게 뭉쳐 있어서 마치 아름다운 설계를 보는 것 같았다. 나는 개인적으로 수강생 +9,999명 되어 있는 네임드 강의보다 김우근 강사님의 강의가 훨씬 좋았다.
오오오...
Reviews 5
∙
Average Rating 5.0
5
이 강의는 단순한 테스트 강의가 아닙니다. 저는 테스트를 작성하기 위한 JUnit, Mockito 등의 사용법을 배우고 적용해 나가는 중이였습니다. 그러다가 단순히 테스트 도구를 사용하는 방법을 넘어, 좋은 테스트 코드, 잘 만든 테스트 코드에 대해 궁금증이 생겼고, 이 강의를 발견했습니다. 강사님의 1편 강의를 재밌게 본 터라 기본적으로 신뢰도가 높았고, 목차의 내용도 흥미로워 보였습니다. 강의를 전부 수강하고 후기를 남깁니다. 이 강의는 단순한 테스트 강의가 아닌, 좋은 아키텍처와 OOP에 대해 고민할 수 있게 도와주는 아주 멋진 강의입니다. 테스트를 짜는 목적이 단순한 회귀 방지였던 저에게, 테스트와 설계는 상호 보완적 관계이며, 기존 레이어드 아키텍처의 문제점과, 레이어드 아키텍처에서 작성하는 테스트의 한계점을 알려 주면서 자연스럽게 좋은 설계에 대해 고민하게 만들어 주었습니다. 문제점들을 이론으로만 짚어주는게 아니라, 코드를 리팩토링 하는 과정을 통해 더 나은 구조와 테스트 코드 작성을 제시해줍니다. 얼마전 Mockito를 처음 배우고, Stubbing을 이용한 테스트에 감탄하고 있던 저에게, Mocktio가 필요했던 테스트들을 외부 라이브러리 없이 순수 자바로 테스트하는 멋진 경험을 선사해 주었습니다. 결국 모든 것은 OOP라는 1편의 말씀이 그대로 이어지는 좋은 강의입니다. 그 외에도 테스트에 필요한 개념들과 강사님의 개인적인 고민이 담긴 의견들을 이야기 해주시는 것도 좋았습니다. 개발 분야에 대한 진중함과 태도들을 간접적으로 느낄 수 있어 많이 배웠습니다. 좋은 강의 감사합니다.
Reviews 48
∙
Average Rating 5.0
Reviews 4
∙
Average Rating 5.0
5
마침 스프링을 공부하고 테스트를 어떻게 작성하는 코드들이 보니 반복되는 의미없는 테스트 작성들이 눈에 보였습니다. 그래서 왜 이런 반복적인 테스트를 작성하는지 의문점이 들었습니다. 그런데 마침 인프런에서 새 강의로 왜 스프링 테스트 개발자들이 작성하는데 실패하는지 라는 강의가 새로 나온걸 보았습니다. 딱 저를 위한 강의다! 해서 과감히 결제를 하였습니다. 완강을 한 후, 역시 후회없는 선택을 한 것 같습니다. 10분 강의를 일시정지를 눌러 하나하나 강사님께서 이야기 하시는 부분이 무엇인지 곰곰이 생각한 것 같습니다. 그래서 강의 시간은 6시간이지만 60시간 만큼의 퀄리티가 있다는 게 느껴졌습니다. 소프트웨어 공학에 대해 시야를 넓혀준 강사님께 감사드립니다.
Reviews 4
∙
Average Rating 5.0
$46.20
Check out other courses by the instructor!
Explore other courses in the same field!