Class 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 Detail

      • annotationEnabler

        private java.lang.Object annotationEnabler
      • previousCl

        private java.lang.ClassLoader previousCl
    • Constructor Detail

      • PowerMockTestCase

        public PowerMockTestCase()
    • 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:
        1. Injects all mock fields (if they haven't been injected already)
        Throws:
        java.lang.Exception - If something unexpected goes wrong.
      • enableReporter

        private void enableReporter()
      • afterPowerMockTestMethod

        @AfterMethod
        protected void afterPowerMockTestMethod()
                                         throws java.lang.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:
        java.lang.Exception - If something unexpected goes wrong.
      • disableReporter

        private void disableReporter()
      • create

        public org.testng.IObjectFactory create​(org.testng.ITestContext context)
        Returns:
        The PowerMock object factory.
      • clearMockFields

        private void clearMockFields()
                              throws java.lang.Exception,
                                     java.lang.IllegalAccessException
        Throws:
        java.lang.Exception
        java.lang.IllegalAccessException
      • injectMocks

        private void injectMocks()
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • isLoadedByPowerMockClassloader

        private boolean isLoadedByPowerMockClassloader()