@BeforeClass and inheritance – order of execution

edit: Answer below is for JUnit, but I will leave it here anyway, because it could be helpful.

According to the JUnit api: “The @BeforeClass methods of superclasses will be run before those the current class.”

I tested this, and it seems to work for me.

However, as @Odys mentions below, for JUnit you need to have the two methods named differently though as doing otherwise will result in only the subclass method being run because the parent will be shadowed.

Leave a Comment