Change log 2.0.0 * PowerMockito changes: ** `verifyStatic` is replaced by `verifyStatic(Class)` ** `mockStatic` does not reset mocking process anymore. As result you may get the `UnfinishedVerificationException` or `UnfinishedStubbingException` ** Possible incapability due toString methods returns by default name of mocked. Change log 1.7.1 * Fixed #832 Provide a new API for verifying static mock and deprecate old for Mockito Change log 1.7.0 ----------------------------- * Added supporting Mockito 2.8.9 for PowerMock 2.x (thanks to Gregor Stamac @gstamac for pull request) * Added supporting global ignore via configuration (issue # #801) * Added supporting org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker via PowerMock configuration (issues #793, #774) * Optimizations in powermock-reflect (thanks to Roman Leventov @leventov for pull request) (#724) * Migrated from Maven to Gradle (#728) * Implement #793 PowerMockMaker for Mockito 2: A new version of PowerMockMaker implemented. It does not conflict with Mockito MockMaker any more. Fix for #701 partially does not work any more, because ByteBuddy implementation of MockMaker always intercept calls to equals and return `true` only in case if passed object is the same instance of mocked object. * Fixed issue #722 IllegalArgumentException is output to standard error (thanks to Kotaro Nanri @k-nanri for pull request) * Fixed issue #717 Regression: MethodNotFoundException * Fixed issue #731 No methods matching the name(s) get were found in the class hierarchy for interfaces * Fixed issue #753 fix to upgrade code to be compatible with later versions of Mockito (thanks to emmaLP @emmaLP for pull request) * Fixed issue #763 whenNew not matching constructor when null is passed as first or last argument. (thanks to @podarsmarty podarsmarty for pull request) * Fixed issue #781 Call mocked equals static method instead of real (thanks to @Ilya-Gh Ilya Ghirici for pull request) * Fixed issue #772: PowerMockIgnorePackagesExtractorImpl should visit interfaces. (thanks to François Jacques @hypnoce for pull request) * Fixed issue with javax.xml and org.w3c. Previously when PowerMock was used with class which works with XML adding ``@PowerMockIgnore({"org.w3c.*", "javax.xml.*"})` was required. See examples: https://github.com/powermock/powermock-examples-maven/blob/master/spring-mockito-xml/src/test/java/org/powermock/examples/spring/mockito/SpringExampleTest.java Change log 1.6.6 (2016-11-04) ----------------------------- * Added support for setting private static final fields in Whitebox.setInternalState (thanks to Andrei Petcu @andreicristianpetcu for pull request) * Added support for specifying constructor parameters for Mockito for whenNew case (Only mock specific calls to new #31) * Fixed #668 @Mock fields are not injected anymore (1.6.5 regression) * Fixed #676 Using Powermock with Roo/AspectJ gives NullPointerException (thanks to Sebastian Saip @ssaip for pull request) * Fixed #656 TooManyActualInvocations when class is prepared for test. * Fixed #695 ClassNotFoundException when loading cglib enhanced classes created by Spring * Fixed Java 6 compatibility issue in org.powermock.utils.StringJoiner (which accidentally referenced Java 7 API's) * Fixed #701 StackOverflowError mocking final class extending non-public abstract class overriding equals method * Fixed #707 PowerMock should ignore and keep synthetic method/fields when modifies class * Fixed #645 jacoco offline instrumentation incompatibility with powermock byte-code manipulation when using @SuppressStaticInitializationFor * Fixed #704 PowerMockito 1.6.5 throws java.lang.SecurityException signer information mismatch * Refactoring: Move ProxyFramework from api modules to `reflect` module. * Renamed org.powermock.reflect.internal.WhiteboxImpl.getAllMetodsExcept to org.powermock.reflect.internal.WhiteboxImpl.getAllMethodsExcept (typo) * Refactoring: Fix performance issues, fix error handling issues, remove unused imports, remove verbose or redundant code constructs. (thanks to Mykhailo Kovalskyi @kovalsky for pull request) * Upgraded Assertj dependency from 3.4.1 to version 3.5.2 * Upgraded Javaassist dependency from 3.20.0-GA to version 3.21.0-GA * Upgraded Objenesis dependency from 2.2 to version 3.4 Change log 1.6.5 (2016-04-30) ----------------------------- * Add ability to chain returns with doReturn() (thanks to "gauee" for pull request) (issue #599) * Code quality improvement, @Override annotation should be used on any method overriding (since Java 5) or implementing (since Java 6) another one * PowerMockRunner now processes JUnit Rules correctly (thanks to Stefan Birkner for pull request) (issue 427) * Added support for @TestSubject in EasyMock API. This is the equivalent of @InjectMocks in Mockito (big thanks to Arthur Zagretdinov for pull request) * Added experimental support for mockito 2.x * Ensuring JVM method size limit is never exceeded. Throw an user frendly exception if method size is exceeded. (thanks to Tomasz Przybyla for pull request) (issue #661) * Fix #214: Whitebox.invokeConstructor may not work as expected with overloaded constructors * Fix #352: PowerMockRunner should run tests defined in super class * Fix #510: Static method mocking with Mockito 1.9.5 and Powermock fails with Java 8 Consumer Interface * Fix #512: @PrepareForTest on method not working with PowerMockRule * Fix #652: PowerMock stubbing void method don't work for overloaded methods * Fix #648: TestNG SkipException doesn't work with PowerMock * Fix #634/#632: Add workaround as fix for Mockito 1+. Wait fix from Mockito team for Mockito 2. * Fix #590: suppress(method) doesn't work on a @Spy/PowerMockito.spy * Upgraded commons-logging dependency to version 1.2 * Upgraded objenesis dependency to version 2.2 * Upgraded TestNG dependency to version 6.9.10. * Upgraded xStream dependency to version 1.4.9. * ASM for PowerMock Javaagent repackaged from new version 5.0.4 Change log 1.6.4 (2015-12-11) ----------------------------- * DelegatingPowerMockRunner now implements Filterable interface to allow running for example individual test methods (thanks to chang-chao for pull request) * Fixed jacoco/powermock integration issue (thanks to Evgeny Astafyev for pull request) * Improvements to StackTraceCleanerProvider which cleans powermock classes from a stack trace * Replaced usage of uberjar mockito-all with mockito-core (thanks to Petr Široký and René Scheibe for helping out) * Code quality improvement, constructors only call non-overridable methods (thanks to Christian Ivan for pull request) Change log 1.6.3 (2015-10-02) ---------------------------- * Mock name in @Mock(name="abc") annotations are no longer ignored for the Mockito API extension * Fixed NPE in withArguments() constructor (thanks to Tomoyuki Saito for pull request) * Upgraded Javassist dependency to version 3.20.0-GA. * Using soft reference in classloader cache * MockClassloader now extends Javassist Loader classloader to implement findClass etc * PowerMock now works better with ByteBuddy (issue 579) * This allows creating mocks in the applyInterceptionPolicy method of MockPolicy, which in turn allows using MockPolicy together with PowerMockRule (issue 581). * Upgraded the powermock-easymock extension to use EasyMock 3.4 Change log 1.6.2 (2015-01-03) ---------------------------- * PowerMockRunnerDelegate annotation now uses @Inherited (thanks to Henrik Kaipe for pull request) * Tests can now have multiple constructors (thanks to Henrik Kaipe for pull request) * Cleanup pom files and added version numbers (thanks to René Scheibe for pull request) * Fix "Test class can only have one constructor" issue that occurs when a JUnit or 3rd-party delegate runner (specified by a PowerMockRunnerDelegate annotation) can only deal with one public constructor. (thanks to Henrik Kaipe for pull request) * Packaged some of the Mocktio classes internally since Mockito is moving from CgLib to ByteBuddy. (thanks to Brice Dutheil for the pull request). * Upgraded Javassist dependency to version 3.19.0-GA. * Upgraded TestNG dependency to version 6.8.21. * The PowerMock EasyMock Api now depends on EasyMock 3.3.1. Change log 1.6.1 (2015-01-03) ---------------------------- * The PowerMock EasyMock Api now depends on EasyMock 3.3. Note that 1.6.0 also works with this version of EasyMock _if_ cglib-nodep 2.2.2 is used as EasyMock transitive dependency. * PowerMock JUnit Module now supports JUnit 4.12 (Thanks to Henri Tremblay for the pull request). * Upgraded TestNG from 6.8.8 to 6.8.13. * Fixed Mockito 1.10.9+ incompatibility, by repackaging CGLIB MockMaker (issue 524). Thanks to Brice Dutheil for the pull request. Change log 1.6.0 (2014-11-27) ----------------------------- * It's now possible to verify private final overloaded methods in the Mockito Extension API. For example: verifyPrivate(tested).invoke(method(MyClass.class, "myOverloadedMethodName", String.class, String.class)).withArguments(anyString(), captor.capture()); * Upgraded Mockito API extension to work with version Mockito 1.10.8. * PowerMock now builds for Java 6 and not Java 5. * You can now use other runners in combination with the PowerMockRunner without using a JUnit Rule. This leaves the actual test-execution to or another runner of your choice. For example tests can delegate to "SpringJUnit4ClassRunner", "Parameterized" or the "Enclosed" runner. This also allows PowerMock to (without any modifications) support future new JUnit-features from day one! Usage example: @RunWith(PowerMockRunner.class) @PowerMockRunnerDelegate(Parameterized.class) // Use the parameterized JUnit in combination with the PowerMockRunner @PrepareForTest(SuppressConstructorDemo.class) public class SuppressConstructorDemoTest { ... } (Big thanks to Henrik Kaipe for this excellent pull request). Change log 1.5.6 (2014-09-04) ----------------------------- * Changed so that the MockClassLoader throws ClassNotFoundException instead of Javassist's NotFoundException when a class isn't found (thanks to Mikael Petterson for the pull request). * Final equals methods should now work with Mockito and not cause stackoverflow (thanks to Peer Hartmann for pull request) * Removed redundant cast when creating a class replicas for final system classes. * Cleaned up some code in the ClassReplicaCreator class * Added support for answers, name and extract interfaces in PowerMockito when using annotations (@Mock). Note that answers doesn't work for final classes or methods! (issue 486). * PowerMockIgnore is now taken into account when using the Java Agent PowerMockRule. * Improved java agent automatic bootstrap mechanism to work better for newer JDK's. * PowerMock now finds default methods in Java 8 (issue 513). * Annotations such as @Mock and @InjectMocks can now be used with the JUnit Java Agent. * Proxy framework is loaded from the the JUnit Java Agent which means that all Whitebox methods work as expected. Change log 1.5.5 (2014-05-28) ----------------------------- * Updated OSGi metadata * MockClassLoader.getResources no longer loads same file twice (thanks to Kelsey Rider for the patch) * Added getResourceAsStream and getResource to DeferSupportingClassLoader which defers loading to the deferring classloader. * Added ability to adjust the classpath when running the a test using the @UseClassPathAdjuster annotation. This is useful when integrating PowerMock with certain third-party JUnit runners (thanks to Jonas Berlin for the patch). * Upgraded to Javassist 3.18.2-GA. * Moved project to github (issue 493). * Upgraded to TestNG 6.8.8. * Removed accidental JUnit dependency to Objenesis and XStream classloading projects. Change log 1.5.4 (2014-01-29) ----------------------------- * Removed OSGi metadata because they didn't work properly * Fixed an issue when setting up private method expectations with multiple arguments in Mockito. * Added support for suppressing static initializers using TestNG (issue 256) (thanks to majorpetya for the patch). * PowerMock Java agent works in Java 8 (issue 475) (thanks to iirekm for help). * Moved bundled asm packages into the powermock package for the PowerMock Java Agent module to avoid classloading issues. Change log 1.5.3 (2014-01-10) ----------------------------- * Added OSGi metadata to manifest files (issue 204) (thanks to Gabor Liptak for patch) * Upgraded to Javassist 3.18.1-GA. * Test case with expectedExceptions no longer fails when using PowerMock with TestNG (issue 366) (thanks to majorpetya for the patch). * Fixed a classloading issue with the JUnit4TestSuiteChunkerImpl (thanks to Robert Gay for the patch) * Updated objenesis to version 2.1 Change log 1.5.2 (2013-11-18) ----------------------------- * Fixed PowerMock OOM (OutOfMemory) issues with Mockito (big thanks to Henrik Karlsson for the patch). * PowerMock EasyMock extension API now supports EasyMock version 3.2. * Added jacoco agent to be deferred by the PowerMock classloader * Updated TestNG dependency to 6.8.7. Change log 1.5.1 (2013-06-19) ----------------------------- * Maven no longer adds classpath to jar manifests when building PowerMock (issue 413). * PowerMockRunner now supports both MethodRules and TestRules to comply with JUnit 4.11 (thanks to "Boris Code" for the patch) (issue 419). * Slf4j MockPolicy in Mockito now works again (issue 431). * Removed synchronized from all MockGateway methods in order to make it work with multi-threaded Mockito. * The PowerMock runner for JUnit now supports assumeTrue(..) statements (issue 408). * Mocked system classes are now invoked when it's casted into another (non-final) type (thanks to Jonatan Jonsson for the patch) (issue 445). * TestNG state is cleaned up in a better way when a test fails (thanks to Jonatan Jonsson for the patch). * PowerMock byte-code manipulation transformers now ignores classes it cannot load. This means that PowerMock works with better SPI's that have compile-time dependencies that are not available at runtime. * Upgraded Javassist to version 1.8.0-GA. * Upgraded to TestNG module to version 6.8.5 * Upgraded to JUnit module to version 4.11 Change log 1.5 (2012-12-04) --------------------------- * Added var-args to mockStatic in the PowerMockito API. You can now do: mockStatic(A.class, B.class, C.class); * Suppression is now working for overridden methods (issue 364, 51). Thanks to hpbeem for the patch. * PowerMock junit module now supports JUnit rules for version 4.9+ (issue 344). Thanks to Andreas Kutschera for the patch. * Fixed is with PowerMock JUnit runner that failed to parse JUnit versions including characters such as 4.9b2. (issue 381). * Mockito extension API now uses Mockito 1.9.5 (issue 398) * Updated TestNG dependency to version 6.8 * Added support for easily mocking all constructors of a class in the Mockito extension API. For example: whenNew(X.class).withAnyArguments().thenReturn(xMock); (issue 405). * Upgraded to Javassist 3.17.1-GA, this means that PowerMock works in Java 7! Change log 1.4.12 (2012-04-05) ------------------------------ * Really added missing class, PowerMockTestCase, to testng full release jar (issue 327). * PowerMock JUnit module now works with JUnit 4.10 (thanks to Diego Coronel for the patch) (issue 367) * Changed name from org.powermock.api.mockito.mockpolicies.Slf4jMockPolicy to org.powermock.api.mockito.mockpolicies.Slf4jMockPolicy in the Mockito extension API. * Upgraded Javassist to version 3.16.1.GA. * DeferSupportingClassLoader now overrides ClassLoader.findResources() which enables classes loaded by MockClassLoader to be to find resources via ClassLoader.findResources(...). Thanks to wrussellmorris for the patch (issue 380). * Updated TestNG dependency to version 6.4 Change log 1.4.11 (2012-01-05) ------------------------------ * Fixed an OutOfMemory issue in PowerMockRunner (issue 346). * Added Sfl4jMockPolicy to the Mockito extension API, thanks to Alexandre Normand for the patch. * Replaced ${version} to ${project.version} in all pom files (thanks to pvdissel for the patch) (issue 287). * Added work-around to stub some final system classes (such as java.util.UUID) (issue 354). * Improved the PowerMock Java agent support. It should now work together with multiple java agents (thanks to Magnus Jungsbluth for the patch) (issue 357). * Upgraded TestNG module to 6.3.1. * Upgraded EasyMock extension API to use version 3.1 of EasyMock. This version should fix a couple of OutOfMemory issues. * PowerMockito is updated to use Mockito 1.9.0 * setUp-method with @Before annotation is no longer executed twice when extending TestCase (issue 356) * Upgraded classloader xstream deepcloner to XStream 1.4.2 (issue 345) Change log 1.4.10 (2011-08-23) ------------------------------ * Added missing class, PowerMockTestCase, to testng full release jar (issue 327). * Fixed test initialization error when using PowerMock Mockito API in Ant (issue 333). * Upgraded to Javassist 3.15 GA (issue 338). * Upgraded TestNG module to TestNG 6.2. * Mockito @InjectMocks annotations on superclasses of test class are no longer ignored (issue 343). * MockClassloader now defers the loading of classes in "org.pitest.*" to the system classloader. This means that you should be able to use PIT (http://pitest.org) without adding @PowerMockIgnore("org.pitest.*") to each test class (issue 337). * PowerMockito now works with Mockito 1.9-rc1 but will not include the new artifact by default because it's still rc (issue 339). * Removed PowerMockRule from full jar in release process (issue 325). Change log 1.4.9 (2011-05-02) ----------------------------- * Fixed an issue when mocking system classes containing fields of type Class, Classloader or synthetic fields such as java.util.ServiceLoader. * TestNG PowerMockObjectFactory now sets the thread context classloader to the PowerMock mock classloader (issue 315). * TestNG PowerMockObjectFactory now only uses PowerMock classloader and byte-code manipulation if the test class or a method declared in this method is annotated with @PrepareForTest or @SuppressStaticInitializerFor. This introduces a non-backward compatible change so if you're currently using mock injection (e.g. annotating a field with @Mock) you must now also use @PrepareForTest or @SuppressStaticInitializerFor for the mocks to be injected (issue 299). * Upgraded TestNG module to TestNG 6.0.1 (issue 316). * Fixed an issue with the PowerMock JUnit runner that prevented a JUnit Rule to throw an exception failing the test (issue 311). * Fixed an issue with test state clearing while running a PowerMock enabled test as an Eclipse PDE test (issue 309). * Classloader based PowerMock JUnit Rules now supports suppressing static initializers * Improved state clean-up in TestNG module when extending from PowerMockTestCase. * Automatic creation and injection of mocks to a field annotated with @Mock does no longer work if you're not extending from PowerMockTestCase in the TestNG classloading module (side-effect of issue 299). * Removed the classloading version of PowerMockRule from the powermock-easymock-full and powermock-mockito-full release jars. You need to download the rule implementations manually since there are now two different implementations to choose from. (issue 318) * Implemented experimental support for bootstrapping PowerMock using a Java agent. With the agent you won't run into classloading issues that you may with the standard way of bootstrapping. The new project is called junit4-rule-agent for JUnit and testng-agent for TestNG. Change log 1.4.8 (2011-02-26) ----------------------------- * Fixed a bug in Whitebox which prevented passing null parameters to methods. * PowerMock now supports mocking static final inner classes and member Enums (issue 95). * Fixed a bug in PowerMockito that sometimes caused the finalize method to be called instead of the expecting method when setting up expectations (issue 308). * Upgraded TestNG module to TestNG 5.14.6 Change log 1.4.7 (2010-12-27) ----------------------------- * The MemberModifier API now checks that the replacing method returns the same type and have the same number of parameters as the original method otherwise an IllegalArgumentException is thrown (issue 285). * Fixed a bug which made it impossible to mock private methods with multiple arguments (issue 289). * Removed some unwanted debug messages from the TestNG module. * Updated javadoc in Whitebox and WhiteboxImpl. * EasyMock and Mockito extension API now supports mocking new invocations with var args parameters when var args paramters is not the first parameter (issue 163). * Various improvements to var args handling for both methods and constructors. * Upgraded to Javassist 3.14 (issue 295). * Upgraded junit module to use JUnit 4.8.2 (issue 296). * You no longer need to prepare system classes that are not final and whose methods are not static, final or native in a special way (by prepare the class calling the system class method) (issue 300). * Added method "defaultConstructorIn" to the MemberMatcher API so that you can e.g. suppress a default constructor using suppress(defaultConstructorIn(SomeClass.class)) (issue 302). * PowerMock now cleans up EasyMock state after each test case which significantly decreases memory consumption. * PowerMock now cleans up most Mockito state after each test case which decreases memory consumption. * Major refactoring of the classloading module. It has been split up in a way that allows for different object deep-cloning mechanisms. The previous implementation is now called powermock-classloading-objenesis and there's also a new one called powermock-classload-xstream. The latter uses X-Stream for deep-cloning. This means that if you're using the PowerMock JUnit Rule you must also depend on one of the two deep-cloner implementations. Change log 1.4.6 (2010-10-13) ----------------------------- * Changed project structure, all group id's are now "org.powermock" but most artifact id's are the same. There are two exceptions, org.powermock.tests and org.powermock.examples. Artifact module-test-powermock has been renamed to module-test-easymock and module-test-powermockito has been renamed to module-test-mockito (issue 234). * Removed all third-party repositories from the pom's to allow for Maven central syncing. * PowerMock can now be built with Maven 3 (issue 283). * Prepared pom's for Maven central synching. * Upgraded the TestNG module to version 5.14 (issue 275). * Fixed a bug in Whitebox which caused some overriden methods to be treated as overloaded (issue 276). Change log 1.4.5 (2010-08-30) ----------------------------- * The EasyMock API extension should now work when testing Eclipse plugins and running the tests as PDE (JUnit Plugin) tests (issue 264) * Deprecated "andReturn" in the stubber API and added "toReturn" instead. The API now reads e.g. "stub(method("methodName")).toReturn(new Object());" * Added the "toThrow" method to the stubber API. You can now do e.g. "stub(method("methodName")).toThrow(new Exception());" (issue 182) * Whitebox#setInternalStateFromContext now support field matching strategies. By default all context fields that matches a field in the target class or instance is copied to the instance. If the strategy is changed from MATCHING to STRICT then an exception will be thrown if the context contains a field that cannot be copied to the target. Note that this change may cause backward incompatibility if you're currently using setInternalStateFromContext in your code. (issue 221) * Fixed an issue that was introduced in version 1.4 when support for partial mocking of instance methods in final system classes not having a default constructor was added. The bug caused an javassist.CannotCompileException exception when mocking certain classes such as java.lang.Console (issue 272). * Removed PowerMock specific classes to support mocking of signed classes in the EasyMock extension API since nowadays EasyMock supports this out of the box. This makes PowerMock less dependent on a specific EasyMock version and fixes and patches in EasyMock automatically applies to PowerMock in the future as well. (issue 273) * Upgraded the TestNG module to version 5.13.1. * Whitebox#newInstance(..) now supports instantiating interfaces and arrays. An exception is thrown when trying to instantiate an abstract type (issue 193). Change log 1.4 (2010-07-22) --------------------------- * Implemeted support for mocking instance methods of final system classes with the Mockito extension API (issue 169) * Partial mocking of instance methods in final system classes not having a default constructor now works in the EasyMock extension API (issue 170) * The deep cloner can now clone java.reflect.Method objects correctly to a different classloader. * Fixed a critical bug in the ClassloaderExecutor which prevented it from running methods returning void. This affected the PowerMockRule which prevented it from executing test methods (even though it looked like it did) (issue 268, also closes issue 245) * Upgraded to Javassist 3.13 (issue 269) * Fixed some problems with Withbox regarding invocation of var args member class constructors and methods (issue 267). * Partial mocking of public static methods now works in Mockito (issue 261) * Better clean-up in test runner which fixes some java.lang.OutOfMemoryError errors in large test suites. Change log 1.3.9 (2010-07-14) ---------------------------------- * Upgraded the Mockito extension API to support Mockito 1.8.5 * Upgraded the EasyMock extension API to support EasyMock 3.0 (issue 259) * Spying with PowerMockito now retains object state (issue 263) Change log 1.3.8 (2010-05-13) ----------------------------- * Fixed a bug in DeepCloner which caused a NullPointerException for arrays containing null values. * Changed groupId of the PowerMock JUnit Rule project to org.powermock.modules. * Included PowerMock rule in the released artifacts * verifyNew with arguments no longer throws NullPointerException when missing expectation in the Mockito extension API. * EasyMock API extension now supports mock creation of classes whose hashCode implementation depends on constructor initialization. * It's now allowed to use verifyNew multiple times just as with verify in standard Mockito (issue 251) * Mockito extension API now supports mocking and stubbing equals and hashcode. * Fixed an issue in the core mock classloader that accidentally caused any previous deferred packages to be overwritten when adding new packages to be ignored. * Upgraded to Javassist 3.12 (issue 254) * Upgraded to TestNG 5.12 (issue 250) * Improved error messages in TestNG when running inside Eclipse Change log 1.3.7 (2010-03-22) ----------------------------- * Added support for JUnit 4.8.1 (issue 226) * Added support for Mockito 1.8.4 * Fixed so that a "mock name" is set in the Mockito extension API. Fixes NullPointerException when e.g. toString is invoked on a mock. (issue 239) * Changed method signature on "mockStatic" to return void in the Mockito extension API. * Fixed the "Internal error: Run delegates were 0" bug when using a test class hierarchy and the PowerMock JUnit runner when no tests are defined in a parent test class (issue 241). * Added support for deep cloning objects containing self references using the DeepCloner. * New experimental approach for bootstrapping PowerMock is supported using a JUnit rule called PowerMockRule (available in JUnit 4.7+). This allows you to use other JUnit runners than the PowerMock one (PowerMockRunner) while still benefiting from PowerMock's functionality. * Added support for suppressing all constructors in a class using suppress(constructorsDeclaredIn(X.class)). * Added support for suppressing all constructors and methods in a class suppress(everythingDeclaredIn(X.class)). Change log 1.3.6 (2010-03-10) ----------------------------- * Added testng to full release project. * Fixed so that classloader executor supports runnable's. * DeepCloner now supports reference cloning. * DeepCloner now supports cloning enum constants. * DeepCloner now supports cloning standard java types (using simple serialization). * DeepCloner now supports cloning fields in a hierarchy. * DeepCloner now supports cloning class fields. * Fixed a bug in the Wildcard matcher which resulted in that classes located in packages containing "junit.", "java.", "sun." in their name was never prepared for test (issue 225). * Fixed so that you can mock anonymous inner classes with the Mockito API extension (issue 227). * Nested classes declared inside the test case are automatically prepared for test. * Minor improvement in the byte-code manipulation; only package private classes are changed to public. * Upgraded he EasyMock extension API to use EasyMock class extension 2.5.2 (due to internal changes in EasyMock it's not backward compatible with older versions). * Upgraded to Objenesis for powermock-reflect to 1.2. * Fixed so that MockGateway now finds the correct method to invoke when several overloaded method candidates are found (issue 229). * Upgraded to Mockito 1.8.3. * Added support for Mockito annotations @Spy, @Captor and @InjectMocks. * Mockito extension now supports real partial mocking for private (and private final) methods (both static and instance methods) using PowerMockito.doReturn(..), PowerMockito.doThrow(..) etc. * Added support for MockSettings and Answers when creating class or instance mocks in Mockito extension, e.g. "FinalClass mock = mock(FinalClass.class, Mockito.RETURNS_MOCKS);". Change log 1.3.5 (2009-12-13) ----------------------------- * Removed EasyMock maven dependencies from the JUnit legacy runner since they're not needed. * Fixed a bug in WhiteboxImpl#findUniqueConstructorOrThrowException which caused an additional constructor to be found when a class was prepared for test (issue 189). * Fixed the maven assembly so that it now produces two full jar files, one for Mockito and one for EasyMock. These contains the sources as well. * Mockito extension API now supports Mockito 1.8.1 & 1.8.2. * java.lang.Object#getClass is no longer mockable by default. The reason is that it may lead to an unexpected method invocation exception using EasyMock in some equal implementations. It's possible to override this behavior. * DeepCloner should now support cloning of static final fields on SUN JVM. * Fixed a minor bug in Whitebox#getInternalState so that a better error message is given when the instance argument is null (issue 205). * Fixed some typos in the javadoc of PowerMockito#verifyNew (issue 187). * Fixed so that Whitebox#getInternalState(..) now supports passing in super types as field-type critiera (issue 210). * Fixed so that Whitebox#getInternalState(..) and Whitebox#setInternalState(..) doesn't cause NPE when too many fields matched the criteria (issue 211). * Basic support for TestNG (5.11) implemented. * Fixed so that Whitebox#invokeMethod now works for overridden methods. * Implemented findResource in classloader, this means that you should be able to locate resources in classpath (issue 143). * JUnit runner and TestNG object factory now clears MockRepository state upon instantiation. This is useful in cases where a previous test has used e.g. PowerMock#createMock(..) to create a mock without using the runner/factory which means that there would be some state left in the MockRepository that hasn't been cleared. Change log 1.3.1 (released 2009-10-28) -------------------------------------- * Critial bug resolved in the PowerMock JUnit 4.7 runner: Before tests would not be executed at all if a JUnit rule was used in the test (even though it looked like they were). This has now been resolved an thus support for JUnit 4.7 rules should _really_ work. * DeepCloner now supports cloning of one dimensional arrays, primitives, enums and collections. * Test case is now always prepared for test even if no @PrepareForTest annotation is specified * Fixed a bug in Whitebox#setInternalState so that it now works to supply an array when specifying a method name again. * Improved javadoc in Whitebox class * Upgraded EasyMock extension API to depend on EasyMock 2.5.2 (EasyMock class extensions are still version 2.4 since that's the latest release right now). Change log 1.3 (released 2009-10-06) ------------------------------------ * Classes that will have their static initializers suppressed are automatically added to prepare for test in mock policies. * Added a toString implementation for TestMethodResultImpl * Added a toString implementation for TestSuiteResultImpl * suppressMethod(Class...classes) now takes a class and additional classes as var args (i.e. suppressMethod(Class cls, Class...classes). This makes it easier to suppress all methods of a particular class for only one class. * Invoking reflection methods now works again. This failed in version 1.2 and 1.2.5 when PowerMock begun supporting mocking of system classes. E.g. MyClass.class.getClassloader() now works again even if MyClass is prepared for test. * The standard JUnit 4 runner has been verified to work with JUnit 4.6 and 4.7. The version dependency for JUnit4 is thus changed from [4.4,4.5] to [4.4,4.7]. * Classes prepared for test in parent test classes are now automatically prepared for test as well. I.e. if Test Case A extends Test Case B and A prepares X.class and B prepares Y.class then both X and Y will be prepared for test. Before only X was prepared for test. * Fixed a bug in Whitebox which prevented it from instantiating classes with constructors combining normal and var-arg parameters. The same was fix was applied to method invocations as well. * Fixed so that WhiteboxImpl#findMethodOrThrowException(..) throws a TooManyMethodsFoundException if a potential method had previously been found and a new matching var-args method was found. * Fixed so that WhiteboxImpl#findConstructorOrThrowException(..) throws a TooManyConstructorsFoundException if a potential constructor had previously been found and a new matching var-args constructor was found. * Fixed a bug so that when Whitebox looks for a var args method it now also checks that the component type of the var args array is the same as the supplied argument type(s). * Implemented so that expectPrivate in the EasyMock extension API can be used without specifying a method name. The method is looked up by using the argument types. * Extended the Whitebox.setInternalState functionality to accept a var-args list of values to set on an object. I.e. you can now do Whitebox.setInternalState(object, myState1, .., myStateN). * Upgraded to Javassist 3.10 (3.11 doesn't work with PowerMock due to a bug or backward incompatibility in Javassist). * Fixed a bug in the EasyMock extension API regarding suppression of methods so that it now uses Whitebox.getMethods(..) instead of Whitebox.getMethod(..). * Mocking of static methods in final system classes now works with the Mockito extension (because of a bug fix in Javassist 3.10) * PowerMock now changes the context class-loader to the MockClassloader which means that you don't need to use @PowerMockIgnore as often as before. This solves many issues with frameworks that creates new instances using reflection like log4j, hibernate and many XML frameworks. This fix is not backward compatible with version 1.2.5! If you've been using PowerMockIgnore in your test you may need to remove it (or update the ignored package list) otherwise the test might fail. * Implemented support for setting internal state from a context (using Whitebox.setInternalStateFromContext(..)). * Error message differ between static or instance type fields when internal state cannot be set because a field wasn't found. * PowerMock now supports mocking instance methods of final system classes (such as java.lang.String). To do this you need to prepare the class that invokes the method of the system class. Note that partial mocking of instance methods in final system classes doesn't yet work if a constructor needs to be invoked on the mock. * You can now mock new instance calls to final system classes in the same was you'd mock any other new instance call. * Improved error message in Whitebox when getting a method or constructor which was not found and no parameter types were supplied. * The state of classes that should have their static intializers suppressed are no longer clear after each atomic test. This means that suppression of static initializers works (again) in test suites. * Begun working with support for TestNG (thanks to Dan Fabulich for helping us with this). * Deprecated Whitebox#getInternalState(Object object, String fieldName, Class where, Class type), use "Whitebox. getInternalState(Object object, String fieldName, Class where)" instead. * Changed return type of Whitebox#getInternalState(Object object, String fieldName) from Object to T. This means that you can avoid cast using e.g. "Whitebox. getInternalState(instance, "myFieldName")". * Changed return type of Whitebox#invokeMethod(..) from Object to T. This means that you can avoid cast using e.g. "Whitebox. invokeMethod(..)". * JUnit test runner now supports JUnit 4.7 rules * Upgraded the Mockito extension to use Mockito 1.8 * Created a reusable component (PowerMockIgnorePackagesExtractorImpl) that can be used by test runners to extract which packages that should be ignored in a test case. * Removed mockStatic(Class type, Method method, Method... methods), mockStaticPartial, mockPartial, mock(Class type, Method... methods) & mock(Class type, Method... methods) from the Mockito extension API. You should use PowerMockito.spy instead. * When using the PowerMock Mock annotation with Mockito the method names (previously used for partial mocking) are ignored. They are no longer needed, just use PowerMockito.spy instead. * Mockito extension API support for private methods expectations using PowerMockito.when(..). * Fixed so that Whitebox error message prints correct parameter types when a MethodNotFoundException is thrown if a method with correct name but wrong parameter types were specified. * EasyMock extension API: You can now manually use replay(..) or verify(..) and then fall back on replayAll(..) verifyAll(..) even if a mock has previously been replayed/verified. I.e. replayAll/verifyAll only replays and verifies mocks that has previously not been manually replayed/verified. * WhiteboxImpl#getField(..) now check for null returned from Class.getSuperclass() to avoid NullPointerException when type is an interface (thanks to Ben Chatelain for the patch) * Deprecated org.powermock.core.classloader.annotations.Mock, you should now use the Mock annotation in respective extension API instead. For EasyMock this is org.powermock.api.easymock.annotation.Mock and for Mockito it's org.mockito.Mock. * Packages ignored for test in parent test classes are now automatically ignored as well when using @PowerMockIgnore. I.e. if Test Case A extends Test Case B and A ignores X and B ignores Y then both X and Y will be ignored in the test case. Before only X was ignored. * The method IExpectationSetters expectNew(String fullyQualifiedName, Object... arguments) in the EasyMock extension API changed return type to IExpectationSetters expectNew(String fullyQualifiedName, Object... arguments). * Improved error message for Whitebox#getConstructor when no constructor was found. * Fixed a bug in PowerMockito's CgLibProxyFramework#getUnproxiedType(..) so that it now _really_ returns the unproxied type. * You can now mock construction of new objects using the Mockito extension. To do so use PowerMockito#whenNew(..), e.g. whenNew(MyClass.class).withArguments(myObject1, myObject2).thenReturn(myMock). Verification can be done with PowerMockito#verifyNew(..), e.g. verifyNew(MyClass.class).withArguments(myObject1, myObject2). * Annotation support has been integrated in the test runners (both for JUnit and TestNG) so there's no need to specify the AnnotationEnabler listener using @PowerMockListener(AnnotationEnabler.class). It works both for the EasyMock and Mockito extension API's. This means that org.powermock.api.easymock.powermocklistener.AnnotationEnabler and org.powermock.api.mockito.powermocklistener.AnnotationEnabler has been deprecated. * Whitebox#getInternalState(..) and Whitebox#setInternalState(..) now uses isAssignableFrom instead of equals when looking for field types. * Added a new api-support project that contains functionality shared between all mock API projects * Mockito extension API now supports suppressing constructors, fields and methods. * ProxyFramework is now registered from the test runner instead of the extension API. This means that Whitebox always works correctly in the test cases regardless if the mock api is used or not. * Test classes are now always prepared for test automatically. This means that you can use suppressConstructor(..) and mock final system classes more easily since you don't have to prepare the actual test class for test. In some cases this change is not backward compatible with version 1.2.5. These cases are when you've tried to suppress a constructor but have forgot to prepare the test class for test as well. * @PowerMockIgnore now accept wildcards, this means that if you want to ignore all classes in the "com.mypackage" package you now have to specify @PowerMockIgnore("org.mypackage.*") (before you did @PowerMockIgnore("org.mypackage.")). * @PrepareForTest now accepts wildcards in the fullyQualifiedName attribute, e.g. you can now do @PrepareForTest(fullyQualifiedName={"*name*"}) to prepare all classes in containing "name" in its fully-qualified name. * Fixed a major issue with the prepare for test algorithm. Before classes were accidentally prepared for test automatically if the fully qualified name of the class started with the same fully qualified name as a class that were prepared for test. This has now been resolved. This may lead to backward incompatibility issues in cases where tests didn't prepare all necessary artifacts for test. * Mockito extension API now supports verification of private methods (for both static and instance methods). Use verifyPrivate(..).invoke(..), e.g. verifyPrivate(myObject, times(2)).invoke("myMethod", argument1, argument2). * Verification behavior of static method in the Mockito extension API has changed. Before you did "verifyStatic(MyClass.class); MyClass.methodToVerify(argument);", now you do "verifyStatic(); MyClass.methodToVerify(argument);". You can also pass a verification mode when verifying static methods: "verifyStatic(times(2)); MyClass.methodToVerify(argument);". This change is NOT backward compatible with version 1.2.5. * Mockito extension API now supports "verifyNoMoreInteractions" and "verifyZeroInteractions" for both instance mocks, class mocks and new instance mocks. * Deprecated setSubstituteReturnValues, getSubstituteReturnValues and addSubtituteReturnValue in MockPolicyInterceptionSettings, you should now use setMethodsToStub, getStubbedMethods and stubMethod instead. * Renamed MockRepository#getSubstituteReturnValue to getMethodToStub and MockRepository#putSubstituteReturnValue to putMethodToStub. * PowerMockito now supports, doAnswer, doThrow, doCallRealMethod, doNothing and doReturn for void methods defined in final classes, final void methods and static methods. Note that if a method is a private void method you should still use PowerMockito#when. * Removed the deprecated classes "org.powermock.PowerMock" and "org.powermock.Whitebox". * PowerMock support API now has a DeepCloner class that you can use to create a clone of an object. This clone can also be cloned to a different classloader. * Added a PowerMock classloading project which can be used to execute any Runnable or Callable in a different classloader. The result of a callable operation will be cloned to the the callers classloader. * Mocking static methods in final system classes works in the Mockito extension API. * AnnotationEnablers only injects to fields that haven't previously been set (i.e. if the field is null). * Added org.powermock.core.spi.listener.AnnotationEnablerListener interface that all AnnotationEnablers must implement. * Implemented a fluent API for suppression, replacing and stubbing (org.powermock.api.support.membermodification.MemberModifier). It uses matcher methods defined in org.powermock.api.support.membermodification.MemberMatcher. Some examples: replace(method(X)).with(method(Y)); // Works only for static methods replace(method(X)).with(invocationHandler); stub(method(X)).andReturn(Y); suppress(methodsDeclaredIn(X.class, Y.class)) suppress(method(X.class, "methodName")) suppress(methods(method(X.class, "methodName"), method(Y.class, "methodName2"))) suppress(methods(X.class, "methodName1", "methodName2")) suppress(field(..)) suppress(constructor(..)); * Deprecated all suppressMethod, suppressField and suppressConstructor methods in the EasyMock extension API. You should now use PowerMock#suppress instead. * PowerMock and PowerMockito now supports stubbing methods (including private methods). Use PowerMock#stub or PowerMockito#stub to accomplish this. * PowerMock and PowerMockito now supports proxying methods, including private methods using replace(..), e.g. replace(method(MyClass.class, "methodToProxy")).with(myInvocationHandler). Every call to the "methodToProxy" method will be routed to the supplied invocation handler instead. * PowerMock and PowerMockito now supports duck typing of static methods, including static private methods using replace(..), e.g. replace(method(MyClass.class, "methodToDuckType")).with(method(MyOtherClass.class, "methodToInvoke")). Every call to the "methodToDuckType" method will be routed to the "methodToInvoke" method instead. * Mock policies now supports proxing methods using proxyMethod(..). * Private inner memeber interfaces are not changed to public anymore during the byte-code manipulation session * PowerMock JUnit4 Runner can now instantiate test classes that have a String constructor if the test class extends from junit.framework.TestCase. Change log 1.2.5 (released 2009-05-05) -------------------------------------- * Mocking of static methods in final system classes such as java.lang.System now works. To do this you need to prepare the class that invokes the method of the system class as well as the actual test case. * Fixed a major issue with mock policies which caused them to fail if a test case had more than one test method. Also fixed so that mock policies works in "setup" methods. * Fixed so that WhiteboxImpl#getMethod no longer fails when invoking proxified interface methods declared in extended interfaces. Previously if e.g. interface A extended B & C and a method was declared in B it wouldn't be found by WhiteboxImpl#getMethod since it only used to traverse the class hierarchy and not the structure of the extended interfaces. * Whitebox#invokeMethod now works without specifying any method name which can increase the refactoring possibilities of the code when invoking unique private methods. * Fixed the error message when a method couldn't be found and only one method was specified (for example when using Whitebox.getMethods(MyClass.class, "onlyOneMethod")). * All field matcher strategies now throws FieldNotFoundException's instead of IllegalArgumentException's. * Upgraded the Mockito API extension to use Mockito 1.7. * Added mockPartial and mockStaticPartial to the Mockito API to allow for easier creation of partial mocks. Change log 1.2 (released 2009-01-30) ------------------------------------ * Upgraded to Javassist 3.9 * The test result related artifacts were moved from package org.powermock.tests.result to org.powermock.core.spi.testresult. * Structural refactoring to remove Structure 101 XS: Moved org.powermock.api.easymock.internal.proxyframework.spi.ProxyFramework to org.powermock.reflect.internal.proxy.ProxyFramework. * Added PowerMock specific exceptions to the reflect project. Instead of getting RuntimeExceptions or IllegalArgument exceptions a more appropriate runtime exception is thrown. For example ConstructorNotFoundException or TooManyFieldsFoundException etc. * Whitebox.getMethods(..) and Whitebox.getFields(..) now throw an MethodNotFoundException if no method or field was found. * Error messages when expecting new now works correctly for inner classes. * Added three new methods to the Whitebox class, these are Whitebox.getInnerClassType(..), Whitebox.getLocalClassType(..) and Whitebox.getAnonymousInnerClassType(..). These methods helps with getting the class type for private inner, local or anonymous inner classes. * Inner member classes declared in class X are automatically prepared for test when X is prepared for test. * PowerMock now follows the semantics of EasyMock verification. This means that invoking an unexpected method of a mock object will cause an AssertionError to be thrown even if verify has been called prior to the method invocation. * Interfaces will now be bytecode manipulated if included in @PrepareForTest or @SuppressStaticInitializationFor. This is useful since interfaces can also contain evil static initializers (using bytecode manipulation or other tricks). Concrete example found in XMLBeans. * Fixed problem with infinite recursion with some hashCode implementations * Possible to mock non-final system classes such as java.net.URLEncoder. To do this you need to prepare the class that invokes the method of the system class as well as the actual test case. * Fixed a NPE bug in WhiteboxImpl#findSingleFieldUsingStrategy when the startClass was null and a field name haven't been found. Change log 1.1.1 (released 2008-12-15) -------------------------------------- * Fixed maven version issues for the junit4-legacy module and junit3 module. * Fixed a major issue with PowerMock test listeners. The PowerMockTestListener.beforeTestMethod(..) was invoked too late which could cause a NullPointerException when invoking setup methods. * Updated javadoc (some errors in the java doc text). Change log 1.1 (released 2008-12-12) ------------------------------------ * Only signed classes are loaded by the signed supporting CGLib naming policy. * Whitebox.invokeConstructor now propagates InvocationTargetExceptions correctly. * Restructured release assemblies to include just the correct things. * Set sources:jar and javadocs:jar to run on every build. * LoggerTest now creates its test log file in ./target/ directory instead of ./ * Major refactoring of project structure, it's now be possible to use PowerMock as a foundation for testability for other mock frameworks. PowerMock core is no longer coupled to EasyMock. * Fixed a serious issue with the classloading hierarchy of PowerMock's JUnit runners. * Implemented support for PowerMock test listeners, to create a listener you need to implement the org.powermock.core.spi.PowerMockTestListener interface and pass the implementation class to the PowerMockListener annotation. * Started Mockito integration. It supports final, static (non-void) and partial mocking using the PowerMock Mockito API. It also supports the Mockito annotations if using the @PowerMockListener(AnnotationEnabler.class) at the class-level of the test case. * Added a new Mock annotation which can be placed on fields to allow for a PowerMock listener to create and inject mock objects. Use the AnnotationEnabler listener from the EasyMock or Mockito API. * Exceptions are no longer wrapped in run-time exceptions when invoking a method using Whitebox.invokeMethod(..). * Major refactoring of the classloader structure and delegation. * Added two new methods to the Whitebox API, getAllInstanceFields and getAllStaticFields. One takes an object as parameter and one takes a class. They return all instance/class fields of the object/class. * Added a FieldDefaulter test listeners that set all instance field to their default value after each test method. This listener can be used to automatically set all instances to null after each test method instead of doing so manually in a tearDown method. * Added three new methods to the PowerMock API, reset(Object...mocks), reset(Class...classMocks) and resetAll(). The methods can be used to reset instance mocks, class mocks or let PowerMock reset all mocks automatically. * mockStaticNice(Class clazz, String... methodNames) was renamed to mockStaticPartialNice in the PowerMock API. * PowerMock and PowerMockito now _really_ follows the EasyMock semantics for partial mocking (e.g. PowerMock.createMock(MyClass.class, null) now mocks all methods of a class whereas PowerMock.createMock(MyClass.class, new Method[0]) mocks no methods of a class). * The @PrepareForTest annotation now accepts interfaces as types. This is useful in situations where you wan't to make sure that a certain interface is loaded by the same classloader as the rest of the mocks. * Updated the tutorial projects to reflect the latest changes in PowerMock. * Errors are propagated correctly when invoking the PowerMock.replay(..) method (i.e. they are no longer wrapped in run-time exceptions). * Added a MockNice and MockStrict annotation which can be placed on fields to allow for the AnnotationEnabler of the EasyMock api to create and inject mock objects. * Changed so that the default suppression value for methods returning java.lang.String is null to conform with EasyMock and Mockito. * Added Whitebox.getFieldsOfType(..) that can be used to retreive all fields of a particular type in a class hierarchy. * Added support for mock policies. A mock policy can be used to make it easier to unit test some code with PowerMock in isolation from a certain framework. Three mock policies are available in the EasyMock API, JclMockPolicy, Slf4jMockPolicy and Log4jMockPolicy which helps with mocking java commons-lang, log4j or slf4j in PowerMock. Use the @MockPolicy annotation at the class-level of the test case to use one of the mock policies. * Whitebox.getMethod(..) sets the accessable flag to true if a method is found. * Added Whitebox.getMethod(Class type, Class... parameterTypes) that let's you get a single method without specifying the method name. * Fixed a bug in WhiteboxImpl.checkIfTypesAreSame(..) that prevented classes to be identified correctly. * Fixed a bug in the PowerMockJUnit44RunnerDelegateImpl that caused a NoClassDefFoundError to be thrown when using JUnit 4.5 when a AssumptionViolatedException was thrown. The reason for this was that JUnit has changed to locatation of this exception. * Added spy functionality of final classes and methods to the Mockito API (experimental). * Fixed so that it works to place the PrepareForTest annotation at methods without specifying it at the class-level first. * Added Whitebox.getField(..) method to get a field somewhere in the hierarchy. * Added Whitebox.getFields(..) method to get fields in a class matching a specific name. * Added methods to the PowerMock API, PowerMock.suppressField(..), that allows to suppress specific fields of a class (no support for primitive final fields right now). * Deprecation: org.powermock.PowerMock and org.powermock.Whitebox have been deprecated, you should now use org.powermock.api.easymock.PowerMock and org.powermock.reflect.Whitebox instead. Change log 1.0 (released 2008-11-18) ------------------------------------ * Changed the pom.xml for the tutorial project so that it's now a stand-alone project. * Fixed so that replay all and verify all also works for createMockAndExpectNew. * Added method createStrictMockAndExpectNew and createNiceMockAndExpectNew * Fixed so that suppressMethodCode returns an empty string for methods returning String. * Fixed a bug in the byte-code manipulation of constructors, modifiers that doesn't need change are now preserved. * Added the PrepareEverythingForTestAnnotation, this annotation can be used to tell PowerMock to modify all classes. * MockGateway doMethodCall now also supports java proxy types. * Implemented the ability to set and get internal state based on field type. This means that you get more refactor friendly code while still being able to set or get internal state. * Implemented the ability to set internal state based on an object type, i.e. you can now do setInternalState(object, myServiceImpl) to set the first field in object which can be assignable to myServiceImpl. This means that you get more refactor friendly code while still being able to set internal state. * Get and setInternalState now separates between class and instance fields, i.e. you cannot set static fields by specifying an instance object. * Updated the tutorial projects to take advantage of the latest features in PowerMock. * Fixed a NPE bug in the AbstractTestClassExtractor.isPrepared(..) method. * The test class is no longer recommended as a PrepareForTest candidate if a NPE occurs inside the test class. * Added createStrictPartialMockForAllMethodsExcept and createNicePartialMockForAllMethodsExcept to the PowerMock API. * The Whitebox API method getAllMethodExcept now traverses the class hierarchy looking for methods. * Fixed a bug in the verifyAll method of the PowerMock API, the state is now properly disposed. * Verify now only clears state of the artifact being verified, this means that you use sequential verify statements again. However you must always use a PowerMockRunner in order to make sure that the full state is properly disposed. * The suppressConstructorCode method of the PowerMock API was renamed to suppressConstructor. * The suppressMethodCode method of the PowerMock API was renamed to suppressMethod. * The suppressConstructorCodeHierarchy method of the PowerMock API was removed, suppressConstructor(..) automatically suppress the full hierarchy so use this method instead. * Added the PowerMockIgnore annotation that can be used to specify packages or classes that should not be loaded by PowerMock's classloader. * Fixed a bug in MockGateway that prevented wrapper/primitive constructors from being correctly executed. * Added support for specifying parameter types for expectNew and createMockAndExpectNew, createNiceMockAndExpectNew, createStrictMockAndExpectNew. * Added expectNiceNew and expectStrictNew, expectNiceNew can be used with no parameters. * Internal refactoring of the chunking mechanism * Fixed a bug in the chunking algorithm that made the test listener clear state for all class loaders even though it should only clear the state for the last one. Fixed this for JUnit4 and JUnit3. Change log 0.9 (released 2008-11-10) ------------------------------------ * Structural refactoring to remove Structure 101 XS: moved WhiteBox implementation to separate class in core and moved IndicateReloadClass * By default Whitebox.getInternalState and Whitebox.setInternalState now traverses the class hierarchy when looking for a field. * Better error message if a NPE is caught in a subclass of a class being prepared for test. * The PrepareForTest annotation now manipulates the full (super) class hierachy by default. This makes it easier to perform mocking of super class methods. * A new annotation called PrepareOnlyThisForTest has been added and works in the same way that PrepareForTest previously did, i.e. ONLY the specified classes are prepared and not the entire hierarchy. * Fixed a bug that made it impossible to invoke vararg constructors. * createMockAndExpectNew now takes expected arguments as the second parameter. * expectNew takes expected arguments as the second parameter. * Invocations of var arg methods, constructors and expectPrivate now works for sub-types of the declared parameter types. * More consistent error messages when expectNew fails. Error messages now takes the parameters into account. * Renamed mockStaticMethodX to mockStaticPartialX * Added javadoc to the release phase * The JUnit4 legacy runner now throws NoTestsRemainException if no tests are found in the test case. * All JUnit4 runners now executes the setUp method before each test and the tearDown method after each test if the test class extends from TestCase. * Fixed an issue in the getAllChunkEntries method of the AbstractTestSuiteChunkerImpl class that caused test methods to be executed in a different order when running in a test suite than running the test stand alone. * Fixed a serious issue when the suppress static constructor state disappeared between chunking sessions. Fixed this for all versions of JUnit 4. This means that chunking and suppression of static initializers now work as expected. * The PowerMock API methods with a syntax like createPartialMockX are renamed to createXPartialMock, e.g. createPartialMockNice is renamed to createNicePartialMock to be more consistent with the normal createMock methods. * Added createNicePartialMockAndInvokeDefaultConstructor and createStrictPartialMockAndInvokeDefaultConstructor to the PowerMock API. * Updated the tutorial projects with * Changed the clean-up mechanisms of PowerMock.replay(..) and PowerMock.verify(..). Should no longer clear unnecessary state. * Implemented two new PowerMock API methods: replayAll and verifyAll(). These can be used to replay and verify all classes and mocks created by the PowerMock API without having to explicitly specify each and everyone. Change log 0.8.5 (releasd 2008-10-30) ------------------------------------- * Fixed so that it's now possible to mock abstract methods * WhiteBox.getMethod(..) now also returns protected and package-private methods. * Whitebox.invokeMethod can now execute methods in a super class. * Whitebox.invokeMethod no longer throws NullPointerException when an argument is null when the method cannot be found * It's is now possible to use sub-types of method parameters when using Whitebox.invokeMethod. * Tests methods starting with "test" are now executed only if the method is annotated with @Test or if the test class extends from TestCase. * Tests are now executed in the order that they are defined in the test case. Change log 0.8.1 (released 2008-10-26) -------------------------------------- * Added PowerMock API method "createPartialMockAndInvokeDefaultConstructor" that invokes a default constructor after mock creation (even if it's private). * createPartialMock now works as expected * Fixed so that it works to mock package private classes (even if they're signed) * It now works to set a static final field after the static initializes have been suppressed. * Fixed a serious bug that caused classes extending java.lang.Object to be non-mockable. Change log 0.8 (released 2008-10-22) ----------------------------------- * The junit4 test module now work with JUnit 4.5 (although using the old, now deprecated, approach of JUnit 4.4). * Upgraded to EasyMock 2.4 * Upgraded to JavaAssist 3.8.0.GA * WhiteBox invoke method and invoke constructor methods now throws an IllegalArgumentException if the first argument is null. * Replay/verify works as expected when mixing classes and instance mocks. * Better error message when expectNew fails due to too few calls to new when a method was invoked using reflection. * Implemented support for nice mocks. * Added more documentation * expectNew(..).andThrow(..) now works with checked exceptions * Added WhiteBox functionality to instantiate a class without invoking its constructor without using byte-code manipulation. Works in multiple JVM's. * mockMethodX is renamed to createPartialMockX * Fixed the error message that was thrown when a constructor was not found when using mocks as arguments with createPartialMock. * Suppress constructor code now works as expected * mockConstruction(..) was removed. You should always use expectNew(..) instead. There's a utility method in PowerMock called createMockAndExpectNew that can be used as a substitute for mockConstruction(..). * Better error message when a class is not replayed when doing expectNew. * Added support to easy suppress several methods in the same class. * doInvokeMethod in PowerMock now catches and deals correctly with InvocationTargetExceptions. * It's now possible to run a single test case in junit4 * Test delegates now implements Sortable * Added support for mocking classes in signed jar files * EasyMock matchers now works in combination with PowerMock's expectPrivate(..) * Added support for invoking var args constructors and methods using Whitebox * Added support for expecting private methods with var args parameter * PowerMock now supports Hamcrest matchers * Exceptions are now propagated correctly from the junit runners. Change log 0.7 (released) ------------------------- * Do not mock hashCode and equals * Added ugly hack for cglib classloading issue with maven * Fixed problems with mocking methods in superclass and modifying multiple classes with same parent * Strict mocking with interface work as expected * Added niceReplayAndVerify * Added logo and improved documentation structure * Follow EasyMock semantics for partial mocking * WhiteBox internalstate support for static fields as expected * Updated assembly and create sources jar files Change log 0.6 (released) ------------------------- * Updated to EasyMock 2.3 and classextension 2.3 * Implemented support for ConstructorArgs * Implemented support for StrictMock * Added possibility to invoke a private method in a subclass of an instance using Whitebox. * Added a support for test classes extending from TestCase when using a custom JUnit runner such as PowerMockRunner. This fix was created for both JUnit4 legacy and JUnit 4.4. * Major internal refactoring. * Fixed major classloading and byte-code manipulation issues. Code coverage tools such as EMMA now works. * Fixed so that it's now possible to invoke private methods using non-primitive and/or non-wrapper values. * Whitebox now throws the correct exceptions to the client and not a wrapped RuntimeException. This means for example that expectNew(..).andThrow(..) works as expected. * Fixed a bug in the PowerMock JUnit 4.4 and legacy runner that reported back the wrong number of tests being executed when @Ignore was used.