Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enables Inheritance on Category.java by adding @Inherited #566

Merged
merged 2 commits into from
Dec 10, 2012
Merged

Enables Inheritance on Category.java by adding @Inherited #566

merged 2 commits into from
Dec 10, 2012

Conversation

gaffa
Copy link
Contributor

@gaffa gaffa commented Dec 5, 2012

As discussed in https://github.com/KentBeck/junit/pull/563 @dsaff suggested to try and add @inherited. This pull request introduces that behaviour.

@gaffa
Copy link
Contributor Author

gaffa commented Dec 5, 2012

I want to add that @inherited supports overwriting the Annotation as far as i know. The approach in #563 would have aggregated the classes. If at some point the implementation is switched that behavioural change should be in awareness.

@@ -23,6 +16,10 @@
import org.junit.runners.Suite.SuiteClasses;
import org.junit.runners.model.InitializationError;

import static org.junit.Assert.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JUnit style is to import individual methods. Sorry.

@dsaff
Copy link
Member

dsaff commented Dec 6, 2012

Good point about replacing superclasses. At this point, no one is expecting any behavior related to categories on superclasses, so we're not breaking anything, and if someone needed the aggregated behavior, we can talk about adding it back in.

@Tibor17
Copy link
Contributor

Tibor17 commented Dec 6, 2012

@gaffa
It looks like you deleted some comment referring to me.

@gaffa
Copy link
Contributor Author

gaffa commented Dec 6, 2012

Yes. I confused something. Never mind because I figured it out. Thanks anyway!

@Tibor17
Copy link
Contributor

Tibor17 commented Dec 6, 2012

This is only about class inheritance of Category annotation and not the mehods?

@gaffa
Copy link
Contributor Author

gaffa commented Dec 6, 2012

http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/annotation/Inherited.html

"Note that this meta-annotation type has no effect if the annotated type is used to annotate anything other than a class."

@category(A.class)
class Ancestor{}

class Inheritor extends Ancestor{}

with @inherited Inheritor would behave exactly as if it would be annotated with @category(A.class) itself.

PS: I still cant get other the guy called Inherited on github. I am sorry but you should really change your nickname :D

@gaffa
Copy link
Contributor Author

gaffa commented Dec 7, 2012

@dsaff everything fine now?
By the way... If it gets merged in soon... Is there any public snapshot-repo? Also is there any release-Roadmap? Sorry for offtopic but I am pretty keen on categorizing our tests asap which is not really possible before this is merged in :)

dsaff pushed a commit that referenced this pull request Dec 10, 2012
Enables Inheritance on Category.java by adding @inherited
@dsaff dsaff merged commit 70fd631 into junit-team:master Dec 10, 2012
@dsaff
Copy link
Member

dsaff commented Dec 10, 2012

Thanks for the patch. Can you please also update the release notes at https://github.com/KentBeck/junit/wiki/4.12-release-notes?

@dsaff
Copy link
Member

dsaff commented Dec 10, 2012

@gaffa, you can get artifacts at https://junit.ci.cloudbees.com/job/JUnit/. @marcphilipp, is Cloudbees automatically maintaining a snapshot repo?

@gaffa, it's been a pretty productive run post-4.11, and I had promised to get 4.12 out pretty quickly. Looking at the things currently marked for 4.12, I don't see anything that couldn't wait another month.

@marcphilipp, any thoughts about timing on 4.12?

@gaffa
Copy link
Contributor Author

gaffa commented Dec 10, 2012

Done. Thanks a lot for accepting this patch. Really makes things a lot better for us (and hopefully others) ;)

@jbcpollak
Copy link

Could a release of 4.12 be made? I'd really like to be able to use this feature, its been merged over a year ago!

@kcooney
Copy link
Member

kcooney commented May 1, 2014

@jbcpollak You can follow #868

@jbcpollak
Copy link

Thanks @kcooney, I will do that.

If anyone is looking for a fix to just this problem, I have created a forked maintenance branch with this change, Maven support, and a few JDK 8 patches here:

https://github.com/jbcpollak/junit/tree/r4.11.x

It should give you 4.11 plus this fix in an easily compilable form.

@ayazlakdawala
Copy link

I have been trying to test the update done for @category with respect to @inherited meta-annotations with Junit 4.12 Beta 2 version and I get the following exception, Kindly advice if I am doing something wrong over here.

java.lang.NullPointerException
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:481)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:306)
at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:241)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:88)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70)
at java.lang.Class.initAnnotationsIfNecessary(Class.java:3178)
at java.lang.Class.getAnnotations(Class.java:3158)
at org.junit.runner.Description.createSuiteDescription(Description.java:123)
at org.junit.internal.runners.ErrorReportingRunner.getDescription(ErrorReportingRunner.java:25)
at org.junit.runners.Suite.describeChild(Suite.java:122)
at org.junit.runners.Suite.describeChild(Suite.java:26)
at org.junit.runners.ParentRunner.getDescription(ParentRunner.java:298)
at org.junit.runner.JUnitCore.run(JUnitCore.java:159)
at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
at org.junit.runner.JUnitCore.run(JUnitCore.java:128)
at org.junit.runner.JUnitCore.runClasses(JUnitCore.java:73)
at *.testInheritance(TestSuite.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

@kcooney
Copy link
Member

kcooney commented Oct 24, 2014

@ayazlakdawala you'll get more help on the mailing list

@bemnet4u
Copy link

bemnet4u commented May 1, 2017

I know this is an old post but curious if @ayazlakdawala figured out what is causing this and a fix? I am seeing the same error.

@kcooney
Copy link
Member

kcooney commented May 2, 2017

@bemnet4u could you provide a minimal, complete and verifiable example (see https://stackoverflow.com/help/mcve) ?

Also since 4.12 has already been released, you might get more eyes on your problem if you post to http://stackoverflow.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants