I was wondering why it is necessary to put @Test above your test methods and what its use is.
Thanks in advance!
I was wondering why it is necessary to put @Test above your test methods and what its use is.
Thanks in advance!
In order to run your unit tests, you have to tell JUnit what the tests are. Usually, you have a lot of tests, so individually listing classes/methods in a configuration file somewhere would become a major headache.
So what the framework does instead is scan all your code for classes that look like tests (using reflection). The old way was to have a defined super-class extends Test
and methods following a naming pattern. Now that we have annotations, you use the @Test
annotation for that.