Skip to content

Instantly share code, notes, and snippets.

@SDiamante13
Created July 27, 2022 21:02
Show Gist options
  • Select an option

  • Save SDiamante13/04fca02b70ab00205ae9c3466d548069 to your computer and use it in GitHub Desktop.

Select an option

Save SDiamante13/04fca02b70ab00205ae9c3466d548069 to your computer and use it in GitHub Desktop.
Remove unneeded test cases as they are covered with the parameterized test now.
package tech.pathtoprogramming.tdd;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import static org.assertj.core.api.Assertions.assertThat;
class AYearShould {
@ParameterizedTest
@CsvSource({
"2001,false",
"1996,true",
"1992,true"
})
void determineThatTheYearIsNotALeapYearForCommonCase(int givenYear, boolean isExpectedLeapYear) {
boolean isLeapYear = Year.isLeapYear(givenYear);
assertThat(isLeapYear).isEqualTo(isExpectedLeapYear);
}
}
class Year {
public static boolean isLeapYear(int year) {
if (year % 4 == 0) {
return true;
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment