Created
September 7, 2018 21:12
-
-
Save ParasoftExamples/94a71f99d280bfb4f876769e8e87b686 to your computer and use it in GitHub Desktop.
Junit Parameterized Tests Example 8
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
public class LoanProcessorParameterizedTest { | |
@ParameterizedTest(name="Run {index}: loanAmount={0}, downPayment={1}, availableFunds={2}, expectApproved={3}, expectedMessage={4}") | |
@MethodSource("testRequestLoan_Parameters") | |
public void testRequestLoan(float loanAmount, float downPayment, float availableFunds, | |
boolean expectApproved, String expectedMessage) throws Throwable | |
{ | |
... | |
} | |
static Stream<Arguments> testRequestLoan_Parameters() throws Throwable { | |
return Stream.of( | |
Arguments.of(1000.0f, 200.0f, 250.0f, true, null), | |
Arguments.of(1000.0f, 50.0f, 250.0f, false, "error.insufficient.down.payment"), | |
Arguments.of(1000.0f, 200.0f, 150.0f, false, "error.insufficient.funds.for.down.payment") | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment