| Summary: | ClimbingMode constructor not flexible for testing | ||
|---|---|---|---|
| Product: | New-Territories-Cycle-Track-Navigation-System | Reporter: | xuntanye2-c |
| Component: | ClimbingMode | Assignee: | xuntanye2-c |
| Status: | RESOLVED FIXED | ||
| Severity: | enhancement | ||
| Priority: | --- | ||
| Version: | 1.0 | ||
| Hardware: | PC | ||
| OS: | Windows | ||
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. |
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.