Skip to content

Commit

Permalink
#169: fixed scope
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerdes committed Mar 11, 2016
1 parent b06de1f commit 89d3b94
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,29 @@

import java.lang.reflect.Method;

import org.junit.gen5.api.extension.AfterAllExtensionPoint;
import org.junit.gen5.api.extension.BeforeAllExtensionPoint;
import org.junit.gen5.api.extension.ContainerExtensionContext;
import org.junit.gen5.api.extension.*;
import org.junit.gen5.commons.util.ReflectionUtils;
import org.junit.rules.ExternalResource;

// very early thoughts - please do not polish yet :)

public class UglyExternalResourceAdapter implements BeforeAllExtensionPoint, AfterAllExtensionPoint {
public class UglyExternalResourceAdapter implements BeforeEachExtensionPoint, AfterEachExtensionPoint {

ExternalResource externalResource;

@Override
public void beforeAll(ContainerExtensionContext context) throws Exception {
public void beforeEach(TestExtensionContext context) throws Exception {
this.findAndInvokeMethod("before");
}

@Override
public void afterAll(ContainerExtensionContext context) throws Exception {
public void afterEach(TestExtensionContext context) throws Exception {
this.findAndInvokeMethod("after");
}




//exception handling?
private void findAndInvokeMethod(String name) throws NoSuchMethodException {
Method method = this.findMethod(name);
Expand All @@ -45,4 +46,5 @@ private Method findMethod(String name) throws NoSuchMethodException {
return this.externalResource.getClass().getMethod(name);
}


}

0 comments on commit 89d3b94

Please sign in to comment.