public abstract class SpincastTestBase extends Object implements BeforeAfterClassMethodsProvider, TestFailureListener, RepeatedClassAfterMethodProvider
Uses a custom Junit runner,
SpincastJUnitRunner.
This runner create a single instance of the test class for all of its tests,
instead of a new instance for each test. It also calls a beforeClass()
method before the tests are run and an afterClass() method after
they are run.
A class extending this will be part of a Guice context
(created using the createInjector method) and
the required dependencies will be injected into it.
Finally, the NAME_ASCENDING option is used to sort the tests. This means you can force the order in which tests are run by prefixeing them with something like : "t01_firstTest", "t02_secondTest", etc.
| Constructor and Description |
|---|
SpincastTestBase() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterClass()
Called after the tests of the class are ran.
|
void |
afterClassLoops()
Called after all the loops of the class
as specified by the @repeat annotation.
|
void |
afterTest() |
void |
beforeClass()
Called before the tests of the class are ran.
|
void |
beforeTest() |
protected abstract com.google.inject.Injector |
createInjector()
The test class must implement this method to create
the Guice injector.
|
protected String |
createTestingFilePath()
Create a temporary test file.
|
protected String |
createTestingFilePath(String relativePath)
Create a temporary test file, using the given relative path.
|
protected void |
deleteTempDir() |
protected com.google.inject.Injector |
getInjector() |
protected SpincastConfig |
getSpincastConfig() |
protected File |
getTestingWritableDir() |
protected void |
setSpincastConfig(SpincastConfig spincastConfig) |
void |
testFailure(org.junit.runner.notification.Failure failure)
You can override this method to be
informed when a test fails.
|
public void beforeClass()
BeforeAfterClassMethodsProviderbeforeClass in interface BeforeAfterClassMethodsProviderpublic void beforeTest()
public void afterTest()
public void afterClass()
BeforeAfterClassMethodsProviderThis will only be called if the beforeClass() method completed successfully, so you can be sure that the instanciation of the class is complete here.
afterClass in interface BeforeAfterClassMethodsProviderpublic void afterClassLoops()
RepeatedClassAfterMethodProviderThis will only be called if the beforeClass() method completed successfully, so you can be sure that the instanciation of the class is complete here.
afterClassLoops in interface RepeatedClassAfterMethodProviderpublic void testFailure(org.junit.runner.notification.Failure failure)
testFailure in interface TestFailureListener@Inject protected void setSpincastConfig(SpincastConfig spincastConfig)
protected SpincastConfig getSpincastConfig()
protected com.google.inject.Injector getInjector()
protected void deleteTempDir()
protected File getTestingWritableDir()
protected String createTestingFilePath(String relativePath)
protected String createTestingFilePath()
protected abstract com.google.inject.Injector createInjector()
main(...) method) or by
creating a custom Injector.Copyright © 2016. All rights reserved.