Tip:
Highlight text to annotate it
X
In this third part of my introduction to jUnit
I'm going to show you how you can create a test suite
I would like to have two classes that include jUnit tests.
Just to make it a little easier and faster
I'm copy-pasting my existing file.
Now we have two files. Each of them
includes the same four unit tests.
I'm going to right-click right here my
package that includes all my unit tests that I want to
consider and I'm going to add
a new 'Other' thing which is
my jUnit test suite. I have jUnit 4 checked;
I'm in my test folder here. It shows me
the potential classes I could choose from.
I see I want to have both and press 'Finish'
So at this point it added an additional
file here. It was called AllTests. So here in my AllTests.java
I have a class called AllTests. It's absolutely empty
but it has two annotations here. And
one of my annotations - the @SuiteClasses -
includes all my test classes
that should be considered when
I run AllTests. So here I'm going to run it.
Notice there're 8 tests hat are going to be executed.
4 from CircleTest, 4 from CopyOfCircleTest.
So if I would go and
remove one of these files - let's say my
original test file - and I would run it again,
I would have four tests
that were executed. All four of them passed and those were the four tests from
my CopyOfCircleTests.