Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You could of course create such a class with a main method and apply your own checks and decide if the test is successful or not.</p> <p>Then you'd be adding more classes, and more tests and things will get a bit messier. Maybe you'd like to run all tests and see their status as a whole, not stopping at the first one that failed. Maybe you'd like to be able to rerun only the tests that failed. Maybe you'd like to run some config section before all of the test methods in a class, and the list can go on.</p> <p>At this point you'd start tinkering around trying to extract common reusable stuff and create some sort of framework for your needs, which JUnit, TestNg, etc are already. I guess this sounds a bit like reinventing the wheel.</p> <p>These frameworks have been around for some time so they have been thoroughly tested and they integrate nicely with IDEs and continuous integration tools. Also many of the communities developing widely used frameworks, such as Spring, have put a lot of work in providing a way to facilitate the integration with test frameworks (custom context-aware runners, mock builders, etc), basically making your life easier.</p> <p>Test classes are "code" as well, and they also have to be clean and well maintained. Using a known test framework makes it easier for team members to understand what you were trying to express, because it "enforces" a standardised way of doing it. This still requires everyone to learn about it, but you have higher chances of reusing that knowledge when switching workplaces, than if you'd be using your own.</p> <p>I'm sure there are more reasons, but these came to mind as I was reading your question. Stefan has also made a good point, a lot has changed since 2007 and this evolution has made things simpler both with Spring and JUnit4.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload