I think I'm having trouble with using parameters correctly in the JUnit assert in my Test method. My assertion fails even though I'm pretty sure my logic checks out.
How do I construct the correct test with assert? Any pointers appreciated :)
public String season(int month, boolean inNorthernHemisphere) {
// For northern hemisphere
// 1,2,12 "Winter"
// 3,4,5 "Spring"
// 6,7,8 "Summer"
// 9,10,11 "Fall"
// inNorthernHemisphere represents northern Hemisphere when true
String season = "";
if (inNorthernHemisphere) {
if (month < 3 || month == 12)
season = "Winter";
else if (month < 6)
season = "Spring";
else if (month < 9)
season = "Summer";
else
season = "Fall";
} else {
if (month < 3 || month == 12)
season = "Summer";
else if (month < 6)
season = "Fall";
else if (month < 9)
season = "Winter";
else
season = "Spring";
}
return season;
}
@Test
//Not correct assertTrue format?
public void testSeason() {
ControlFun cf = new ControlFun();
boolean north = true;
boolean south = false;
assertTrue("Winter" == cf.season(2, north)));
assertTrue("Winter" == cf.season(9, south)));
}