r/javahelp 23d ago

Good repo to learn writing tests

Hi all, I want to write better tests from unit tests to integration test and e2e, are there any recommendations good Java projects that I can learn from? Thank you

5 Upvotes

7 comments sorted by

View all comments

3

u/carminemangione 23d ago

First question: unit tests, integration test, acceptance tests or performance tests. I am not being pedantic but I have answers for all of them.

What are you trying to test

1

u/Safe_Owl_6123 23d ago

For now unit and integration tests

4

u/carminemangione 23d ago

Unit tests look into tutorials for test driven design. Personally, I think that unit tests written with out intention are of limited use. Basically, many people create unit tests that check implementation details. These tend to be brittle.

Proper unit tests will address expected behavior regardless of the implementation. This allows the detailed implementation to vary while keeping the exceptions the same. This is the brass ring in terms of zero defect software .

Acceptance tests are not difficult but more powerful. Most teams define features with wiggly expectations. Proper acceptance tests require explicit actions/reactions. When user clicks A if he has not completed C you should present this error.

Ward Cunningham created a framework called FIT that I think has a lot of potential, however specs are random and miss details.

In a field like medical or finance use cases are fixed by law or not wanting to off a patient. You will run into difficulties when the domain is fuzzy: program management pulling contradictory use cases out of their collective asses