JUnit tests using Java 8 virtual extension methods

"Craig P. Motlin" <[email protected]> Sat, 2 Nov 2013 13:17:42 -0400
Newsgroups gmane.comp.java.junit.user
Message-ID <CAJyUq7q+nwWGzcZHdE8obXBs9u7q1C1vUNvOfcSSPJziqOLutQ@mail.gmail.com>
I've been experimenting with Java 8 features together with JUnit, and I
found that the default JUnit runner won't find and run virtual extension
methods tagged with @Test. It seems that JUnit scans classes and
superclasses for tests, but not interfaces. I added logic to look for
non-abstract methods in interfaces, and are annotated as tests.
https://github.com/motlin/junit/compare/junit-team:master...master

I was able to make this change and keep -source 1.5 and -target 1.5,
because it only relies on older reflection capabilities. It's just that
before Java 8, all declared methods on an interface would be abstract.
However, the test I wrote uses Java 8, of course.

Please let me know what you think of this feature, and the approach I took.