Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Couple of nitpicks ;-)

  • Loading branch information...
commit 1fa373f01d126d437f08a57a7b5e7a7ec0a01b85 1 parent cbf46b8
@jherault jherault authored
Showing with 13 additions and 5 deletions.
  1. +13 −5 src/main/java/org/junit/runners/Parameterized.java
View
18 src/main/java/org/junit/runners/Parameterized.java
@@ -177,7 +177,8 @@ public Object createTest() throws Exception {
List<FrameworkField> fields = getTestClass().getAnnotatedFields(Parameter.class);
if (!fields.isEmpty()) {
if (fields.size() != fParameters.length)
- throw new Exception("Wrong number of parameters and @parameter fields. @parameter fields counted: "+fields.size()+", available parameters: "+fParameters.length+".");
+ throw new Exception("Wrong number of parameters and @parameter fields."+
+ " @Parameter fields counted: "+fields.size()+", available parameters: "+fParameters.length+".");
testClassInstance = getTestClass().getJavaClass().newInstance();
for (FrameworkField f : fields) {
Field field = f.getField();
@@ -186,7 +187,10 @@ public Object createTest() throws Exception {
try {
field.set(testClassInstance, fParameters[index]);
} catch(IllegalArgumentException iare) {
- throw new Exception(getTestClass().getName() + ": Trying to set "+field.getName()+" with the value "+fParameters[index]+" that is not the right type ("+fParameters[index].getClass().getSimpleName()+" instead of "+field.getType().getSimpleName()+").", iare);
+ throw new Exception(getTestClass().getName() + ": Trying to set "+field.getName()+
+ " with the value "+fParameters[index]+
+ " that is not the right type ("+fParameters[index].getClass().getSimpleName()+" instead of "+
+ field.getType().getSimpleName()+").", iare);
}
}
} else {
@@ -223,7 +227,11 @@ protected void validateFields(List<Throwable> errors) {
for (FrameworkField f : annotatedFieldsByParameter) {
int index = f.getField().getAnnotation(Parameter.class).value();
if (index < 0 || index > annotatedFieldsByParameter.size()-1) {
- errors.add(new Exception("Invalid @parameter value: "+index+". @parameter fields counted: "+annotatedFieldsByParameter.size()+". Please use an index between 0 and "+(annotatedFieldsByParameter.size()-1)+"."));
+ errors.add(
+ new Exception("Invalid @Parameter value: "+index+". @Parameter fields counted: "+
+ annotatedFieldsByParameter.size()+". Please use an index between 0 and "+
+ (annotatedFieldsByParameter.size()-1)+".")
+ );
} else {
usedIndices[index]++;
}
@@ -231,9 +239,9 @@ protected void validateFields(List<Throwable> errors) {
for (int index = 0 ; index < usedIndices.length ; index++) {
int numberOfUse = usedIndices[index];
if (numberOfUse == 0) {
- errors.add(new Exception("The index "+index+" is never used."));
+ errors.add(new Exception("@Parameter("+index+") is never used."));
} else if (numberOfUse > 1) {
- errors.add(new Exception("The index "+index+" is used more than once ("+numberOfUse+")."));
+ errors.add(new Exception("@Parameter("+index+") is used more than once ("+numberOfUse+")."));
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.