Created
January 22, 2020 19:27
-
-
Save maosmurf/4d439f932232aedf0882f23f8c1304e4 to your computer and use it in GitHub Desktop.
JUnit5 @ParameterizedTest
This file contains 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
import org.junit.jupiter.api.BeforeAll; | |
import org.junit.jupiter.params.ParameterizedTest; | |
import org.junit.jupiter.params.provider.Arguments; | |
import org.junit.jupiter.params.provider.MethodSource; | |
import java.util.stream.Stream; | |
import static org.junit.jupiter.api.Assertions.assertEquals; | |
public class DigitParserTest { | |
private static DigitParser parser; | |
@BeforeAll | |
static void beforeAll() { | |
parser = new DigitParser(); | |
} | |
@ParameterizedTest(name = "should parse {1}") | |
@MethodSource("provideDigitsAndNumbers") | |
public void digitShouldEqualInput(String[] input, int digit) { | |
assertEquals(digit, parser.parse(input)); | |
} | |
private static Stream<Arguments> provideDigitsAndNumbers() { | |
return Stream.of( | |
Arguments.of(new String[]{ | |
" _ ", | |
"| |", | |
"|_|", | |
" " | |
}, 0), | |
Arguments.of(new String[]{ | |
" ", | |
" |", | |
" |", | |
" " | |
}, 1) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment