Improving Unit Testing Using ApexMocks Framework
Traditional unit testing on the Force.com platform can be a time consuming business. For developers with an enterprise background in Java or C#, one of the things they may miss is something called a mocking framework. Unit tests for Apex are often what an enterprise developer might think of as more of an integration test – for the component being tested, they might need to setup a lot of data records, insert them into the database, make sure data for any dependent components is setup correctly… all of this takes time to both code and to execute when the test is run. With the FinancialForce ApexMocks framework (which is heavily based on mockito
, a leading mocking framework for Java) developers are able to write true unit tests – focusing 100% on testing the logic of the component they are developing, with no need to worry about inserting data and such like. This frees developers up to hopefully be far more productive and also creates the possibility of a full suite of unit tests being run very quickly, maybe every time someone commits to source control or your continuous integration server runs a new build. Source code can be found here https://github.com/financialforcedev/fflib-apex-mocks/
Please see http://code4cloud.wordpress.com
for full details and documentation.