Package org.powermock.tests.utils.impl
Class AbstractTestSuiteChunkerImpl<T>
- java.lang.Object
-
- org.powermock.tests.utils.impl.AbstractCommonTestSuiteChunkerImpl
-
- org.powermock.tests.utils.impl.AbstractTestSuiteChunkerImpl<T>
-
- All Implemented Interfaces:
RunnerTestSuiteChunker
,TestSuiteChunker
- Direct Known Subclasses:
JUnit4TestSuiteChunkerImpl
public abstract class AbstractTestSuiteChunkerImpl<T> extends AbstractCommonTestSuiteChunkerImpl implements RunnerTestSuiteChunker
Abstract base class for test suite chunking, i.e. a suite is chunked into several smaller pieces which are ran with different classloaders. A chunk is defined by thePrepareForTest
annotation and whichever test-method annotation the actual implementation-class specifies by overriding the methodAbstractCommonTestSuiteChunkerImpl.testMethodAnnotation()
. This to make sure that you can byte-code manipulate classes in tests without impacting on other tests.
-
-
Field Summary
Fields Modifier and Type Field Description protected List<T>
delegates
protected Set<Class<?>>
delegatesCreatedForTheseClasses
protected int
testCount
-
Fields inherited from class org.powermock.tests.utils.impl.AbstractCommonTestSuiteChunkerImpl
DEFAULT_TEST_LISTENERS_SIZE, INTERNAL_INDEX_NOT_FOUND, NOT_INITIALIZED, testAtDelegateMapper, testClasses
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractTestSuiteChunkerImpl(Class<?> testClass)
protected
AbstractTestSuiteChunkerImpl(Class<?>... testClasses)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract T
createDelegatorFromClassloader(ClassLoader classLoader, Class<?> testClass, List<Method> methodsToTest)
void
createTestDelegators(Class<?> testClass, List<TestChunk> chunks)
Create the test delegators needed for a whole class.int
getDelegatorIndex(int testIndex)
Get the junit runner delegate that handles the test at indextestIndex
.protected MockingFrameworkReporterFactory
getFrameworkReporterFactory()
int
getInternalTestIndex(int originalTestIndex)
Get the internal test index for a junit runner delegate based on the "real" original test index.protected Object
getPowerMockTestListenersLoadedByASpecificClassLoader(Class<?> clazz, ClassLoader classLoader)
Class<?>[]
getTestClasses()
-
Methods inherited from class org.powermock.tests.utils.impl.AbstractCommonTestSuiteChunkerImpl
chunkClass, getChunkSize, getMockClassLoaderFactory, getTestChunk, getTestChunks, getTestChunksEntries, registerProxyframework, testMethodAnnotation
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.powermock.tests.utils.RunnerTestSuiteChunker
getTestCount
-
Methods inherited from interface org.powermock.tests.utils.TestSuiteChunker
getChunkSize, getTestChunk, getTestChunks, getTestChunksEntries, shouldExecuteTestForMethod
-
-
-
-
Method Detail
-
getPowerMockTestListenersLoadedByASpecificClassLoader
protected Object getPowerMockTestListenersLoadedByASpecificClassLoader(Class<?> clazz, ClassLoader classLoader)
-
createTestDelegators
public final void createTestDelegators(Class<?> testClass, List<TestChunk> chunks) throws Exception
Create the test delegators needed for a whole class.- Specified by:
createTestDelegators
in interfaceRunnerTestSuiteChunker
- Throws:
Exception
-
createDelegatorFromClassloader
protected abstract T createDelegatorFromClassloader(ClassLoader classLoader, Class<?> testClass, List<Method> methodsToTest) throws Exception
- Throws:
Exception
-
getInternalTestIndex
public int getInternalTestIndex(int originalTestIndex)
Get the internal test index for a junit runner delegate based on the "real" original test index. For example, the test may need to run a single test, for example the test with index 3. However since PowerMock may have chunked the test suite to use many classloaders and junit delegators the index (3) must be mapped to an internal representation for the specific junit runner delegate. This is what this method does. I.e. it will iterate through all junit runner delegates and see if they contain the test with index 3, in the internal index of this test delegator is returned.- Parameters:
originalTestIndex
- The original test index as seen by the test runner.- Returns:
- The internal test index as seen by PowerMock or
-1
if no index was found.
-
getDelegatorIndex
public int getDelegatorIndex(int testIndex)
Get the junit runner delegate that handles the test at indextestIndex
. Throws aRuntimeException
if a delegator is not found for the specific test index.- Parameters:
testIndex
- The test index that a delegator should hold.- Returns:
- The index for of the junit runner delegate as seen by JTestRack.
-
getTestClasses
public Class<?>[] getTestClasses()
-
getFrameworkReporterFactory
protected MockingFrameworkReporterFactory getFrameworkReporterFactory()
-
-