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
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 AdempiereTestcase.java, which has all the required implementation support to prepare junit test cases
Now let us make changes to support Junit testcases of callout. We need to make code changes in AdempiereTestcase.java class.
Step 5.1 Add a new private method setFieldValue() in AdempiereTestcase.java
- gridTab – object of gridTab on which we want set values
- calloutFieldName – Field on which we need to set the data
- 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 AdempiereTestcase.java
It has four parameters,
- hashmap – Contains map of field names and its values
- windowName – Based on the window name, the window id will be derived.
- calloutTabIndex – Index of the tab in the given window on which we want conduct test
- ctx – Context
In this method, create gridtab object and call setFieldValue() method for each field, which intern executes the callout.
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.