Skip to content

Commit 5cf443e

Browse files
committed
Change context creation to once per class
We noticed that the time gained from not having to create a Context in every test greatly offset the time lost by now having multiple tests share the same context.
1 parent 1bf020e commit 5cf443e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/test/java/org/scijava/ops/AbstractTestEnvironment.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
import java.util.Arrays;
44

5-
import org.junit.After;
6-
import org.junit.Before;
5+
import org.junit.AfterClass;
6+
import org.junit.BeforeClass;
77
import org.scijava.Context;
88

99
public abstract class AbstractTestEnvironment {
1010

11-
protected Context context;
12-
protected OpService ops;
11+
protected static Context context;
12+
protected static OpService ops;
1313

14-
@Before
15-
public void setUp() {
14+
@BeforeClass
15+
public static void setUp() {
1616
context = new Context(OpService.class);
1717
ops = context.service(OpService.class);
1818
}
1919

20-
@After
21-
public void tearDown() {
20+
@AfterClass
21+
public static void tearDown() {
2222
context.dispose();
2323
context = null;
2424
ops = null;

0 commit comments

Comments
 (0)