frankiee12a9 / test-driven-devevelopment-practice-study-using-java-spring-boot

TDD practice study with Spring-boot MVC and REST API (on working progress)
2 stars 1 forks source link

issues for image images uploading and project relevant works #1

Open frankiee12a9 opened 1 year ago

frankiee12a9 commented 1 year ago

test-driven strategy image

frankiee12a9 commented 1 year ago

Test-driven development combined with Agile Principle TDD

frankiee12a9 commented 1 year ago

What is TDD?

TDD is a discipline that helps you not only to create automated tests for your code but mainly to drive your implementation, guided by the tests' specifications. There are a few caveats about creating tests after the fact, and these are some of the problems that TDD tries to tackle.

Some credits covered by TDD:

  1. Your production code can be hard to test since it was not initially designed to be testable.
  2. You cannot prove your tests ensure a part of the system works as expected. To do that, you would have to change the current implementation to something else, see the test failing, and change it back to the original state.
  3. It can be boring to create tests after you've done all the mental work. You have already thought about the whole algorithm, which can feel like a duplication of work.
  4. You end up biased with the current implementation, affecting the quality of your tests.

By following TDD principles, you SHOULD

Before creating any production code, you should always start your code with a failing test. Then, you work your way to create that code that makes this failing test pass. This approach to development ensures that code is written to meet the test requirements. It also forces the developer to think about the requirements before writing their implementations, which are more likely to meet the user's needs. There are 3 laws that describe how TDD should be done in practical terms.

Here's a snippet from Uncle Bob's Clean Coder book:

  1. You are not allowed to write any production code until you have first written a failing unit test.
  2. You are not allowed to write more of a unit test than is sufficient to fail—and not compiling is failing.
  3. You are not allowed to write more production code that is sufficient to pass the currently failing unit test

References:

  1. https://reqtest.com/testing-blog/agile-testing-principles-methods-advantages/
  2. https://www.simpliaxis.com/resources/principles-of-test-driven-development
  3. https://trilon.io/blog/tdd-with-nestjs#Creating-the-project-and-starting-with-a-test
  4. https://stackabuse.com/test-driven-development-for-spring-boot-apis/
frankiee12a9 commented 1 year ago

current database EER schema diagram image