Sunday, June 12, 2016

Debugging Test Cases of WSO2 Products

Almost all the WSO2 product sources have Tests embedded with them. So if you build a WSO2 product (i.e. with mvn clean install terminal command) , those tests are executed. These tests are written using WSO2 Test Automation Framework which is basically using the test engine TestNG.

Anyway when we build a WSO2 product and then what if one of these Tests fail. How to find what is the actual place and what is the actual reason for the error.  By Debugging..!! eh.. But how can we debug Test cases, while building a product? Remember these tests are executed when building the product but not when running a product. Will mvn clean install -debug 5005 work ? Unfortunately no. ! Because maven is not happy to do so. ;-) 

So here is the solution. Pretty simple. We are using maven.surefire.debug property for this.
  1. Insert debug points wherever required in the test cases.
  2. Configure remote debugging in idea with port 5005 (we are using 5005 as it is the default set port)
  3. Go to <product_home>/modules/integration/<required_test_module> on terminal, and enter,
         mvn clean install -Dmaven.surefire.debug
  4. Click "Debug" button on the idea to debug with the above set configurations.
  5. That is all. Wait until the debug points are hit.
  • If u want only to debug a single test case, just uncomment others in the testing.xml
  • If u want to debug the whole "integration" module, just run above command being at that required maven module root location, in terminal. 
  • In case if the IDE debugger, displays that the debugger is "Disconnected from the target VM, address: 'localhost:5005', transport: 'socket' " or something like that message, just click on debug button, again and again until the debugging is not disconnected again but the debug points are hit.
  • If u want to go to the Carbon Management console or other web UI s , while debugging, you can go there too via the url, displayed on the terminal. (if any redirection bothers u here, u would have to address it by changing the ports and port offset values adequately )

No comments:

Post a Comment

Comments are highly appreciated... :-)