Step to Reproduce: When running the below segment of code as junit test, the code didn't cover for the listTrails and findTrailsByDifficulty functions. private ClimbingMode cm = ClimbingMode.getInstance(); @Test public void testTrailListing() { ClimbingTrailRepoManager ctrm = new ClimbingTrailRepoManagerStub(); String actualString = ctrm.list(); String expectedString = "Test trail"; assertEquals(expectedString, actualString); } @Test public void testFilterDifficulty() { ClimbingTrailRepoManager ctrm = new ClimbingTrailRepoManagerStub(); String actualString = ctrm.filterByDifficulty(8); String expectedString = "Test trail"; assertEquals(expectedString, actualString); } Actual Result: The listTrails and findTrailsByDifficulty functions are not covered. Expected Result: The test code coverage should increase, the code in the ClimbingMode class, listTrails and findTrailsByDifficulty, should be covered.
Solution: A new constructor public ClimbingMode(ClimbingTrailRepoManager ctrm, Scanner scan, BookmarkManager bmManager,CyclingMode cm) is used so that the input parameters can accept stubs for testing.