Monday, January 12, 2015

Writing Integration Tests for WSO2 ESB

What are Integration Tests ?
               Basically there are unit tests and integration tests we need to write after writing a function or a feature. Unit tests are functional tests which are written to test that the written piece of code is  working in expected way.Integration tests are written to automate working scenarios. for example
in WSO2 ESB if we need to send a message to BE through ESB we need to manually configure ESB for such scenario. (deploying configuration,Sending message through client..etc). So all steps done in manually are need to be automate in Integration Tests.

Architecture used when writing Integration Tests
                   Technically as standard and practise we are using following architecture when writing integration tests. integrationtestarchitecture.jpg
We have admin services written in ESB .So UI calls admin services via service stubs.So when wrtting tests we need to do it in same manner. We have admin clients written using service stubs and those admin clients used in  Integration Util classes for write Tests.

Writing Integration Tests   

                     When you writing Integration test for WSO2 ESB. you need to checkout product-esb from wso2 git repository[1]. Then you don't need to build whole product-esb.if you can it is ok.if there are built failures then you can copy already built zip file of ESB and put it under  
 product-esb/modules/distribution/target      
and then build from inside the integration module.  Integration module consists of admin clients and Integration test utils and actual integration tests.    
We are using testng as testing framework and so we have dependency for testng. we  need to add entries for the tests we written to the  testng.xml file. which resides in the resources folder of test module.

Debugging Integration Tests

    you can use following commands for debug Integration tests
  
      -Dmaven.surefire.debug
Or you can add following configuration to the surefire plugin configuration in pom.xml file.
-Xms512m -Xmx1024m -XX:MaxPermSize=128m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006

No comments:

Post a Comment