I'm having difficulties finding a hard definition of the word "test case". Some sources claim that a test case is a class that extends TestCase
. Other sources claim that a test case is a single test method. The JUnit documentation is unclear, it appears to me the words "test case" and "test" mean the same:
The
Test
annotation tells JUnit that thepublic void
method to which it is attached can be run as a test case. To run the method, JUnit first constructs a fresh instance of the class then invokes the annotated method. Any exceptions thrown by the test will be reported by JUnit as a failure. If no exceptions are thrown, the test is assumed to have succeeded.
So what exactly is a "test case", and what is its relationship to a "test"?
I'd point you over to the JUnit documentation on TestCase. In it, it describes three conditions for what it denotes a TestCase:
The setUp and tearDown portion I think are critical to understanding here. It's not just simply that a test case is but one annotated method. The test case is that method plus the initialization and destruction of the frame on which a test will be run.
So to answer your question, a test is one annotated method which attempts to verify the workings of a single method while a test case is that test plus the frame in which it will be run.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With