|
GettingStarted
API'sPowerMock consists of two extension API's. One for EasyMock and one for Mockito. To use PowerMock you need to depend on one of these API's as well as a test framework. Currently PowerMock supports JUnit and TestNG. There are three different JUnit test executors available, one for JUnit 4.4+, one for JUnit 4.0-4.3 and one for JUnit 3. There's one test executor for TestNG which requires version 5.11+ depending on which version of PowerMock you use. Writing testsWrite a test like this: @RunWith(PowerMockRunner.class)
@PrepareForTest( { YourClassWithEgStaticMethod.class })
public class YourTestCase {
...
}Sample code is available in subversion: JUnit 3 requires a different setup by creating a suite, since test runners are not available. Please view some examples: Maven setupJUnitTestNGNon maven usersJUnit: Download the EasyMock zip-file with PowerMock and all its dependencies and add those to your project. TestNG: Download the EasyMock zip-file with PowerMock and all its dependencies and add those to your project. Mockito JUnit: Download the Mockito zip-file with PowerMock and all its dependencies and add those to your project. TestNG: Download the Mockito zip-file with PowerMock and all its dependencies and add those to your project. Or You could also download the EasyMock jar-file or Mockito jar-file in a single file and then download the dependencies separately. Need to bootstrap using a JUnit rule?
Java agent based bootstrappingUse the PowerMock Java Agent if you're having classloading problems when using PowerMock. |
Hi, the links to the code examples on this page appear to be broken (under "Writing tests")
Fixed, thanks for pointing out.
Is there any chance that you guys can put all those help documents into a ZIP file so we can download from the Downloads page?