-
-
Save SDiamante13/319889a8b05853d9416f4a5c9fe0e58b to your computer and use it in GitHub Desktop.
Fully replace existing test cases with parameterized tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package tech.pathtoprogramming.tdd; | |
| import org.junit.jupiter.api.Test; | |
| 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); | |
| } | |
| @Test | |
| void determineThatTheYearIsAStandardLeapYear() { | |
| boolean isLeapYear = Year.isLeapYear(1996); | |
| assertThat(isLeapYear).isTrue(); | |
| } | |
| @Test | |
| void anotherLeapYear() { | |
| boolean isLeapYear = Year.isLeapYear(1992); | |
| assertThat(isLeapYear).isTrue(); | |
| } | |
| } | |
| 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