Automated Unit Testing of Adempiere Codes

Problem Statement

For product like Adempiere, which provides huge set of functionality off-the-shelf, the major challenge customer face is quality of the customized codes. Since the ERP is often considered as backbone of the company, obviously business expect high quality delivery to ensure that it always works correctly to ensure that their employee are focussed on the actual business work. While their immediate focus remain on the regression test automation, what they also need to know is that there are development tools, which can minimize their overall cost and improve the quality. That is where jUnit comes into play. Due to whatever reasons, jUnit has not been widely used in Adempiere world and we strongly believe that this makes life easier for the development team. The reusable unit test scripts allows developer to continue his focus on the current work, while jUnit ensure that he has not broken anything in the already completed work. We strongly believe that if ERP application architecture inherently supports building of test scripts and if these scripts can be prepared as part of development life cycle of the project, then it becomes additional advantage to produce high quality software.

Scope Of This Article

This article covers three topics
1. Steps to prepare Junit test cases for Adempiere
2. Changes we need to make to enable Adempiere for Junit testing of callouts
3. Steps to prepare Junit case for Adempiere callout

You can of course generalize the concepts talked over here to test other parts of your Adempiere code as well.


• Adempiere 370
• JUnit

For the business user, who may not have exact idea about jUnit, you can consider this as a test suite, which allows developer to define execution path through which the programming control shall flow by using appropriate input data. Also, it is assumed that in order to execute an already written test cases, the developer may need to make minimal amount of changes to be able to test reasonably good amount of codes. In general, The JUnit testing framework is standard unit testing API for Java


Let us see the steps we need to follow to implement Junit testcases. Adempiere has implicit support for Junit testcases. Adempiere code base has class, which has all the required implementation support to prepare junit test cases

Step 1:
Create a new test class by extending AdempiereTestCase class

Step 2:
Overide setUp() method, to set the required data for Junit testcase

Step 3:
Create your own test method. The method name should start with “test” keyword. You can use assertEquals() or related assert methods to validate the output of test case.

Step 4:
Now run the testcase. However, before you run the testcase make sure is in right place as mentioned in

Step 5:
Now let us make changes to support Junit testcases of callout. We need to make code changes in class.

Step 5.1 Add a new private method setFieldValue() in

It has three parameters,

  1. gridTab – object of gridTab on which we want set values
  2. calloutFieldName – Field on which we need to set the data
  3. value – Value that is set in the field

In this method, set the value and call the method to invoke callout

Step 5.2 Add new protected method testMyCallout() in

It has four parameters,

  1. hashmap – Contains map of field names and its values
  2. windowName – Based on the window name, the window id will be derived.
  3. calloutTabIndex – Index of the tab in the given window on which we want conduct test
  4. ctx – Context

In this method, create gridtab object and call setFieldValue() method for each field, which intern executes the callout.

Step 6:
Create a new test class for callout by extending AdempiereTestcase class

Step 7:
Create your own test method and the method name should start with “test” keyword and it will call testMyCallout() method of

Step 8:
Now run callout Junit testcase

Step 9
See the test report in eclipse. Green color indicates test case is executed successfully:


With minor change in Adempiere application, Adempiere supports automation of Unit testing for code changes including callout, which in turn helps development team in identifying the problems in early stages of development. In previous blog we have discussed automation of functional testing and if you combine that with the unit testing and its automation then this definitely ensure that you have better quality delivery.

Along with unit testing, unit test automation, solution test and regression test automation, at Walking Tree we also make use of continuous integration and code coverage measurement to ensure that our customers receive the top class quality. Walking Tree practices and encourage businesses to take advantage of Adempiere. In case you are looking for professional assistance, you can reach us by visiting our website.


Tagged with: , , , ,
Posted in ADempiere

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

We Have Moved Our Blog!

We have moved our blog to our company site. Check out for all latest blogs.

Sencha Select Partner Sencha Training Partner
Xamarin Authorized Partner
Recent Publication
%d bloggers like this: