hr.fer.junit.grading.command_line.ProgramArguments Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of junit-grading Show documentation
Show all versions of junit-grading Show documentation
Testing library to run with grading student examination.
The newest version!
package hr.fer.junit.grading.command_line;
import java.util.EnumSet;
import java.util.List;
import com.beust.jcommander.IStringConverter;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParameterException;
public class ProgramArguments {
@Parameter(names = "-tg", description = "test group (default is all test groups)")
public String testGroup = "all";
@Parameter(names = "-p", description = "package names to find tests", required = true, variableArity = true)
public List packages;
@Parameter(names = "-gm", description = "Grading matrix file (default is looking for 'gradingMatrix.csv' in CWD and in classpath)")
public String gradingFilePath = "";
@Parameter(names = "-h", help = true, description = "help")
public boolean help;
@Parameter(names = "-m", description = "Running modes: normal - prints summary, details - prints details, statistics - print statistics (testGroup, number of tests, test IDs)", converter = ModeConverter.class)
public Mode mode = Mode.NORMAL;
public enum Mode { NORMAL, DETAILS, STATISTICS }
public static class ModeConverter implements IStringConverter {
private String param;
public ModeConverter(String param) {
this.param = param;
}
@Override
public Mode convert(String value) {
try {
return Mode.valueOf(value.toUpperCase());
} catch (IllegalArgumentException e) {
throw new ParameterException("Invalid value for " + param + " parameter. Allowed values:" +
EnumSet.allOf(Mode.class));
}
}
}
}