Skip to content

Instantly share code, notes, and snippets.

@ParasoftExamples
Created September 7, 2018 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ParasoftExamples/a4f09960f5fb3e4addb0f539cf2152c9 to your computer and use it in GitHub Desktop.
Save ParasoftExamples/a4f09960f5fb3e4addb0f539cf2152c9 to your computer and use it in GitHub Desktop.
Junit Parameterized Tests Example 7
@RunWith(JUnitParamsRunner.class)
public class LoanProcessorParameterizedTest2 {
@Test
@Parameters(method = "testRequestLoan_Parameters")
public void testRequestLoan(float loanAmount, float downPayment, float availableFunds,
boolean expectApproved, String expectedMessage) throws Throwable
{
...
}
@SuppressWarnings("unused")
private static Object[][] testRequestLoan_Parameters() throws Throwable {
// Parameters: loanAmount={0}, downPayment={1}, availableFunds={2}, expectApproved={3}, expectedMessage={4}
return new Object[][] {
{ 1000.0f, 200.0f, 250.0f, true, null },
{ 1000.0f, 50.0f, 250.0f, false, "error.insufficient.down.payment"},
{ 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