Class PowerMockTestCase

java.lang.Object
org.powermock.modules.testng.PowerMockTestCase

public class PowerMockTestCase extends Object
A PowerMock base class that may be used as a base class for all TestNG test cases that uses PowerMock.
  • Field Details

    • annotationEnabler

      private Object annotationEnabler
    • previousCl

      private ClassLoader previousCl
  • Constructor Details

    • PowerMockTestCase

      public PowerMockTestCase()
  • Method Details

    • beforePowerMockTestClass

      @BeforeClass protected void beforePowerMockTestClass() throws Exception
      Throws:
      Exception
    • afterPowerMockTestClass

      @AfterClass protected void afterPowerMockTestClass() throws Exception
      Throws:
      Exception
    • beforePowerMockTestMethod

      @BeforeMethod protected void beforePowerMockTestMethod() throws Exception
      Must be executed before each test method. This method does the following:
      1. Injects all mock fields (if they haven't been injected already)
      Throws:
      Exception - If something unexpected goes wrong.
    • afterPowerMockTestMethod

      @AfterMethod protected void afterPowerMockTestMethod() throws Exception
      Must be executed after each test method. This method does the following:
      1. Clear all injection fields (those annotated with a Mock annotation)
      2. Clears the PowerMock MockRepository
      Throws:
      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 Exception
      Throws:
      Exception
    • injectMocks

      private void injectMocks() throws Exception
      Throws:
      Exception
    • isLoadedByPowerMockClassloader

      private boolean isLoadedByPowerMockClassloader()