Unfortunately, these tests can be hard to customize. In my case ... I wanted to @Ignore some tests in the superclass, which implemented a TestCase.
Here's why: It turns out that the @Ignore annotation doesn't cascade upwards for TestCase derived unit tests. Not quite sure why, but I assume its in the logic of how TestCases implement run(..) by default.
In any case its pretty easy to work around this by overriding the run() methods in your unit test class which descends from a TestCase.
static final ListIGNORE= Arrays.asList( "testToIgnore", "test2ThatIDontLike", "test3ThatTakesTooLong" ); public void run(TestResult result) { //We ignore the tests above. the @Ignore annotation doesnt //work for TestCase descendents. And thus, to keep //we have a custom run implementation here. if (IGNORE.contains(getName())) log.warn("SKIPPING: " +getName()); else super.run(result); }
This will do the same thing ultimately as adding Ignore annotations in the superclass.
No comments:
Post a Comment