Currently, all of my JUnit tests extend from a common base class that provides methods tagged with @BeforeClass
and @AfterClass
annotations - all thes
I came across similar problem (Spring was not an option and i don't write TestSuites in maven projects) so i wrote simple junit runner to solve this problem.
You need to write SharedResource class and mark your test to require that resource.
public class SampleSharedResource implements SharedResource {
public void initialize() throws Exception {
//init your resource
}
}
@RunWith(JUnitSharedResourceRunner.class)
@JUnitSharedResourceRunner.WithSharedResources({SampleSharedResource.class})
public class SharedResourceRunnerATest {
...
Sources at https://github.com/eanlr/junit-shared-resources-runner