How to debug integration tests in the WSO2 Identity Server
Recently, I need to debug the integration tests in the WSO2 Identity Server product and the patched code with applied changes. So I’ll share my experience on debugging integration tests for the product IS.
Before debugging let’s start with running the integration tests…
Get a clone from https://github.com/wso2/product-is.git or download the product-is source.
Run below maven command from product-is directory by skipping test cases.
mvn clean install -U -Dmaven.test.skip=true
Now you can replace the zip file resides in <product-is-home>/modules/distribution/target folder of the newly build product-is with the .zip file of the patched product with the changes you have applied.
Navigate to <product-home>/modules/integration and run below command to start the integration test for the product.
mvn clean install
Tip 01: Let’s say if you want to run the tests in tests-backend, simply navigate to <product-is-home>/modules/integration/tests-integration/tests-backend and run the above. Like that, if you need to run tests for individual test cases, navigate to the corresponding folder for the test case which is in the same location and run the above command.
Tip 02: If you need to run the integration tests related to a particular class or set of classes, just comment out the other unwanted test classes in the testng.xml which is inside the resource folder of your targeted directory. Don’t comment the listeners. This will reduce the time to run the tests by a considerable amount.
Let’s debug the integration tests
If you need to debug the integration tests in the product-is repository, just configure debug in IntelliJ IDEA and add the debug points. Then you can simply run the below command to debug the integration tests.
mvn -Dmaven.surefire.debug test
Let’s debug code in another repo while running integration tests in product-is
Find the automation.xml file inside the resources directory of your targeted test directory.
Uncomment “<parameter name=”cmdArg” value=”debug 5005" />” line in automation.xml file and run the command, “mvn clean install”.
Then you can start the debug in the repository that you wish to debug when the product-is is listening to the debug port.
I hope this will helpful for you :) Bye until next time…