question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[JUnit 4.13 regression] @BeforeClass shadowing in superclass doesn't work

See original GitHub issue

In JUnit 4.13 version the @BeforeClass method of superclass is run even if it is shadowed by current class, which is not as expected according to current JUnit 4.12 behaviour and @BeforeClass javadoc:

The "@BeforeClass" methods of superclasses will be run before those of the current class,
unless they are shadowed in the current class.

Repro code:

class Junit413RegressionSuperclass {
  @BeforeClass
  public static void beforeAll() {
    System.out.println("beforeAll - superclass");
  }
}

public class Junit413Regression extends Junit413RegressionSuperclass {
  @BeforeClass
  public static void beforeAll() {
    System.out.println("beforeAll - class");
  }

  @Test
  public void test() {
    System.out.println("test - class");
  }
}

Expected output (JUnit 4.12):

beforeAll - class
test - class

Actual output (JUnit 14.13-SNAPSHOT):

beforeAll - superclass
beforeAll - class
test - class

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
kcooneycommented, Feb 27, 2018
0reactions
kcooneycommented, Mar 28, 2018

Sent out #1514

This change only affects static methods. The behavior of non-static methods is subtlety different in 4.13 due to the fixes for bridge methods.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TestNG @BeforeClass doesn't run from super class if it not an ...
The problem is you have the same method name between A and B. When TestNG is looking for configuration methods, it won't find...
Read more >
Bug List
Chandra, RESO, FIXE, JUnit Launch configuration dialog selects JUnit3 while ... [extract superclass] should also work on types without methods, 2006-04-04.
Read more >
HBASE Changelog - Google Git
HBASE-22146, SpaceQuotaViolationPolicy Disable is not working in Namespace level ... HBASE-23664, Upgrade JUnit to 4.13, Minor, integration tests, test.
Read more >
JIRA - Gradle
Key Summary Assignee Reporter GRADLEREV‑7 Rename 'empty' build type Luke Daley Adam Murdoch GRADLEREV‑8 Needs a mention in the release notes. Luke Daley Adam Murdoch GRADLEREV‑9...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found