When it comes to remote debugging(with maven) your test cases, place the breakpoints in the code, and add below command to the terminal.
mvn clean install -Dmaven.surefire.debug
Once it reaches to "Listening to port 5005" ,start remote debug on port 5005 in your IDE. This will trigger the build process with remote debugging.
If you need to debug your code, while executing some process using the product (ex: Running a human task sample using WSO2 BPS ) , place below command on the terminal.
$ ./wso2server.sh debug 5005