I am writing junit test cases and using ECLEMMA for checking unit test coverage. I have following code in ServerClass.class This class is setting the status of a server.
public class ServerClass{
private boolean isStarted;
public static final String MESSAGE_START = "Started";
private void setStarted( boolean isStarted ) {
this.isStarted = isStarted;
}
public String start() {
setStarted( true );
return ServerClass.MESSAGE_START;
}
}
I have a test case in my test class:
@Test
public void startTest(){
ServerClass serverClass = new serverClass ();
assert("Started".equals( serverClass. start() )); // 3 of 4 branches missed
}
In eclipse, after running eclemma, I am getting a yellow dot in assert statement and code coverage is low. Please help me in understanding the coverage logic and solution.