Added proper conditions for on each execution

This commit is contained in:
Marcin Grzejszczak
2020-07-31 12:46:35 +02:00
parent cd58c2c69a
commit 59dd620415

View File

@@ -91,12 +91,16 @@ public class StubRunnerExtension implements BeforeAllCallback, AfterAllCallback,
@Override
public void afterEach(ExtensionContext context) throws Exception {
if (this.afterAllCalled.get()) {
if (extensionOverStaticField()) {
return;
}
after();
}
private boolean extensionOverStaticField() {
return this.afterAllCalled.get() || this.beforeAllCalled.get();
}
@Override
public void beforeAll(ExtensionContext extensionContext) {
try {
@@ -108,7 +112,7 @@ public class StubRunnerExtension implements BeforeAllCallback, AfterAllCallback,
@Override
public void beforeEach(ExtensionContext context) throws Exception {
if (this.beforeAllCalled.get()) {
if (extensionOverStaticField()) {
return;
}
before();