Inheritance of Categories
I need to Annotate all our IntegrationTests. As I realized they all inherit from only like 3 different abstract tests I felt like maybe I am ready already because I simply can annotate the abstract class. Just that this behaviour is not as expected.
Example:
@Category(IT.class) public class A{ @Test public void testInAnnotatedClass() { System.out.println("inheritance: method in annotated class ran."); } }
public class B extends A{ @Test public void testInInheritingClass() { System.out.println("inheritance: method in inheriting class ran."); } }
Running this will result in only testInAnnotatedClass() being ran.
If the Category annotation was annotated by java.lang.annotation.Inherited, then the test B would be category as well.
I have cloned your repo and implemented the functionality with an optional Parameter "inherited" in Category that defaults to false. I further changed the Categories-Runner to evaluate this Parameter and support inheritance. This does not change the current behaviour but supports optional inheritance. Im just too dumb to understand how to ask you to merge it back :) Its only one commit containing a one-line-change to Category one Method in Categories and some Code changes in Categories. I also added a simple test demonstrating that no changes to default behaviour are made and that the optional inheritance works.
@gaffa, there should be a "Pull Request" button at the top of your fork. That should get you on your way to creating an official pull request. Thanks!
Perfect. Thank you!
@other people interested in this: http://tech.groups.yahoo.com/group/junit/surveys?id=3125322
It looks like this issue can be closed as it has been resolved by pull request #566
Agreed.