[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [stellation-res] Work merging Unit tests
|
Mark,
> What I'd like to do is propose adding a new master test runner, which
> will run all of the suites in the unittest project. To do this, we
> would add a method "static void addTests(TestSuite suite)" to each
> of the unit tests; and the current "suite" method in each of the
> current test suites would be replaced with boilerplate:
>
> public static TestSuite suite() {
> TestSuite result = new TestSuite();
> addTests(result);
> return result;
> }
>
> Then, in the master unit test class, when you add a suite,
> you just add
> one line to its "suite" method, to call the "addTests" method of
> your new test suite class.
So in the end, you have two methods in each test class, the suite method and
the addTests method, right?
For quite some time now, I have the habit of only writing a suite method and
adding sub-suites to it in there:
public static Test suite() {
TestSuite suite = new TestSuite(ThisClass.class);
suite.setName("A descriptive name, something better than the
classname");
suite.addTest(SubSuiteClass.suite());
// Add other subsuites here.
}
You only have one method per class where to look. Giving a Class object to
the TestSuite constructor will let it detect all test methods through
reflection. Using the suite method in both master and sub suites gives you
the opportunity to run any suite you like. E.g. if you use the Eclipse JUnit
test runner on a sub suite, it will build the sub suite using the suite
method, not through the addTests method.
Setting a more readable name is always nice in test runners like the Swing
GUI test runner and the Eclipse JUnit test runner. You will see nice
categories with a clean name...
Ringo