Junit ignore test cases, classes using @ignore

I am a huge fan of Junit 4.5. It is very simple in its approach and test cases are simpler than ever before. I liek the idea of embedding unit test cases within the same class. With junit 4.5 there needs to be a single @Test annotation before the method and thats what is required to run it as a junit test case. I use ant’s junit task to execute my tests. 

Recently i ran into a small issue which was related to interfaces, abstract classes and classes with no junit tests present in the source directory. I had an option to include only test classes in a fileset but i preferred using batchtest, both are ant resource collections.

Ant will always return an error in these cases. I found a way around by using @ignore for all classes which ant junit should ignore. Anyone having a better way ?


package com.vivek.design.patterns;

import org.junit.Ignore;

@Ignore("interface")

public interface FlyBehaviour {

void fly();

}

Class above is from Head First Design Patterns

~ by Vivek on December 16, 2008.

Leave a Reply