Automated testing of Adempiere


Problem Statement

As we know Adempiere is an open source ERP Application, which is affordable, functionally rich, scalable and easy to use, there is no prize for guessing that there is a huge effort behind making this possible. Being one of the best ERP solution, it has following important aspects that the stakeholders must keep in mind

• There are hundreds of functional scenarios
• Thousands of lines of codes exist to implement these scenarios and
• The scenarios are functionally highly Interlinked

When any application is having the above features, it is often daunting task for the Quality Assurance (QA) team to ensure the best quality to meet the expectation of the stakeholders. Even minor changes in the functionality may potentially break functionality somewhere else and it becomes important to identify and test all the related scenario before the changes are approved for the release. This often takes significant time of the high end QA resources. Hence, every time manually testing all the functionalities is very expensive and sometimes people even find it monotonous. In these specific cases, QA team generally looks for automation of the testing. When QA team decides to go for automation, they consider the following factors

• Whether application supports test automation
• Ease of writing(recording) and executing (playing) test cases
• Ease of bundling the test cases together

Scope of the article
With minor code changes, Adempiere supports automated testing. As part of this article, we cover the changes that we need to make to enable Adempiere for automated testing. We go on to show how to record and playback sample test case.

Prerequisite
• Adempiere 370
• Selenium IDE( I have taken selenium as example, sahi or any other tool can be used )
• Firefox Browser

Basic Law of Automated Testing
Automated testing runs with simple law that every widget or entity in the application should have unique and consistent identity across installations. As long as application can ensure uniqueness and consistency, recording and playback of test cases is a smooth job.

Adempiere architecture maintains for uniqueness for most of widgets that appear on screen through AD Field concept in the back end. So we don’t need to build uniqueness, but we need to fine tune this uniqueness to make recording test cases easy.

Steps to Make Adempiere Ready for Test Automation

Step 1: New class to Implement IdGenerator
Create a new class to Implement IdGenerator. Here you need to implement three methods (nextComponentUuid, nextPageUuid, nextDesktopId) of this interface.

Step 2: Enable ZK in your ID Generator
Make changes in zk.xml to invoke the newly created ID Generator while preparing Ids for widgets. You need to add the following statement in zk.xml

Step 3: Set special attribute in common locations
Make code changes in all places where windows, tabs and fields are dynamically generated to set the special attribute. This special attribute will be used as identifier while recording the test case. Example code in Weditor.java, in constructor to set the attribute
String gridTabName = gridField.getGridTab() != null ? gridField.getGridTab().getTabNo() + "_" + gridField.getGridTab().getTableName() : "";
comp.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE,
"unqField_"
+ gridField.getWindowNo()
+ "_" + gridTabName
"_" + gridField.getColumnName()

You need make similar change in all the places where tabs, windows, menus are being created.

Step 4: Once all the changes are done, prepare installer and launch the application. Now Application is ready to record the test cases.

With this you are set to be able to perform automated testing.

Record Test Script

Below is steps to record sample login test script

  1. Launch Adempiere Application
  2. Launch Selenium IDE
  3. Click on record button, Default it is enabled
  4. Now start testing login screen on Adempiere

Below screen shows a sample screen while recording the test

Playback the Test Script
When you playback the test script, you can see that login test case gets executed automatically as shown in below sequence of images:
• Login window is played back

• Now Role window appears automatically

• It automatically logs into the application

• Finally, automatic log off happens

Performance Notes
Using ID Generator in production will have some performance impact so you need to have different zk.xml for testing and production environments.

Summary
With minor change in Adempiere application, Adempiere is well suited for automated testing and it saves lot of effort for the QA team and assures better quality to end customer. At Walking Tree we assist you in making effective use of Adempiere and in case you are looking for professional help, you can always reach us by visiting our website.

References
http://red1.org/adempiere/viewtopic.php?f=28&t=1507&p=7327&hilit=selenium#p7327
http://books.zkoss.org/wiki/ZK_Developer%27s_Reference/Testing/Testing_Tips
http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/sys/IdGenerator.html

Tagged with: , , , , ,
Posted in ADempiere, EagleRP

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

We Have Moved Our Blog!

We have moved our blog to our company site. Check out https://walkingtree.tech/index.php/blog for all latest blogs.

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