We have put build breakers in our CI process for failing the build for insufficient junit coverage. The problem is with how to increase the code coverage because earlier we had broken down the methods in to smaller private methods due to sonar complexity issue.Now we need to work our way to add more junits to test each of the methods.
what are the best options?
1) Change the access modifier to protected or default? I have already seen the question of how to test private method. 2) Use reflection? 3) how best to work towards increasing branch coverage?
Example:
Class A {
public Object complexLogicMethodA(){
//1.Call private method B
methodB();
//2.Call private method C
methodC();
//3.Call private method D
methodD();
//Based on
}
private methodD(){
if(){
//some code here
}else{
//Some code here
}
}
}