Package org.powermock.modules.testng
Class PowerMockTestCase
- java.lang.Object
-
- org.powermock.modules.testng.PowerMockTestCase
-
public class PowerMockTestCase extends java.lang.Object
A PowerMock base class that may be used as a base class for all TestNG test cases that uses PowerMock.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Object
annotationEnabler
private java.lang.ClassLoader
previousCl
-
Constructor Summary
Constructors Constructor Description PowerMockTestCase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
afterPowerMockTestClass()
protected void
afterPowerMockTestMethod()
Must be executed after each test method.protected void
beforePowerMockTestClass()
protected void
beforePowerMockTestMethod()
Must be executed before each test method.private void
clearMockFields()
org.testng.ITestObjectFactory
create(org.testng.ITestContext context)
private void
injectMocks()
private boolean
isLoadedByPowerMockClassloader()
-
-
-
Method Detail
-
beforePowerMockTestClass
@BeforeClass protected void beforePowerMockTestClass() throws java.lang.Exception
- Throws:
java.lang.Exception
-
afterPowerMockTestClass
@AfterClass protected void afterPowerMockTestClass() throws java.lang.Exception
- Throws:
java.lang.Exception
-
beforePowerMockTestMethod
@BeforeMethod protected void beforePowerMockTestMethod() throws java.lang.Exception
Must be executed before each test method. This method does the following:- Injects all mock fields (if they haven't been injected already)
- Throws:
java.lang.Exception
- If something unexpected goes wrong.
-
afterPowerMockTestMethod
@AfterMethod protected void afterPowerMockTestMethod() throws java.lang.Exception
Must be executed after each test method. This method does the following:- Clear all injection fields (those annotated with a Mock annotation)
- Clears the PowerMock MockRepository
- Throws:
java.lang.Exception
- if something unexpected goes wrong.
-
create
public org.testng.ITestObjectFactory create(org.testng.ITestContext context)
- Parameters:
context
- the test context.- Returns:
- The PowerMock object factory.
-
clearMockFields
private void clearMockFields() throws java.lang.Exception
- Throws:
java.lang.Exception
-
injectMocks
private void injectMocks() throws java.lang.Exception
- Throws:
java.lang.Exception
-
isLoadedByPowerMockClassloader
private boolean isLoadedByPowerMockClassloader()
-
-