junit-team/junit — pull request #752 by flpa (2013-10-21 23:48:04+00:00)
Title: Proposed fix for #380: @BeforeClass and @AfterClass methods are still run even if no tests will be run.

Here's my proposed fix for #380.
In order to execute @BeforeClass and @AfterClass methods as well as @ClassRules only if there are any tests remaining, I retrieve the list of filtered children before anything else is done, and filter ignored methods. For convenience I added FrameworkMethod.isIgnored() - in case this kind of self-awareness is unwanted this can be changed easily.
If there are no tests to be run remaining, a special case object statement is returned to maintain the signatures of the protected methods.

There's one specific change in behavior I'm not sure about: Previously the execution of getFilteredChildren() in runChildren(...) was nested inside a try-finally that notified the scheduler in the finally-block. This is no longer the case since the children are passed to that method as an input parameter. I don't know if this could cause bad side-effects.

Any comments and remarks would be appreciated. It's the first time I got in touch with the JUnit source and there's still a lot to learn.
Thanks!