I want to do a ParameterizedTest
with @ValueSource
, i have readed many tutorials including Guide to JUnit 5 Parameterized Tests:
/**
* The {@link Class} values to use as sources of arguments; must not be empty.
*
* @since 5.1
*/
Class<?>[] classes() default {};
So i tried the following :
@ParameterizedTest
@ValueSource(classes = {new Mandator("0052", "123456", 79)})
void testCalculateMandateI(Mandator value) {
//code using Mandator here
}
Mandator class:
public class Mandator {
private String creditorPrefix;
private String retailerCode;
private int mandateIdSequence;
public Mandator(final String creditorPrefix, final String retailerCode, final int mandateIdSequence) {
this.creditorPrefix = creditorPrefix;
this.retailerCode = retailerCode;
this.mandateIdSequence = mandateIdSequence;
}
public String getCreditorPrefix() {
return creditorPrefix;
}
public String getRetailerCode() {
return retailerCode;
}
public int getMandateIdSequence() {
return mandateIdSequence;
}
}
But i get the following error from IntelliJ , hovering above @ValueSource :
Attribute value must be a constant
What am i doing wrong here ? What am i missing ?