Skip to content

Commit

Permalink
add java test
Browse files Browse the repository at this point in the history
  • Loading branch information
issacto committed Jun 25, 2023
1 parent 1623ad3 commit 1fa8b5b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void loadArgProgramPaths(){
String applicationSourceDirectory = Config.getApplicationSourceDirectoryPathString();
if(options.isEmpty()){
// return error when no program is passed
throw new PossibleInternalLogicErrorException(Messages.get("ERR005"));
throw new CommandLineArgumentException(Messages.get("ERR030"));
}
for (OptionKey optionKey : options.keySet()) {
if (optionKey.shortKey.equals(Constants.PROGRAMS_OPTION) || optionKey.longKey.equals(Constants.PROGRAMS_OPTION)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ ERR027 = ERR027: NumericFields.dataTypeOf() was called with empty fieldName.
ERR028 = ERR028: NumericFields.setDataTypeOf() was called with empty fieldName.
ERR029 = ERR029: NumericFields.setDataTypeOf() was called with null dataType.

ERR030 = ERR030: Command line missing program argument.


WRN001 = WRN001: No test suite directory for program %1$s was found under directory %2$s.
WRN002 = WRN002: No test suite files were found under directory %1$s.
WRN003 = WRN003: DirectoryNameMatcher caught IOException on file %1$s.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,15 @@ public void it_throws_when_no_value_is_passed_for_the_last_argument_and_it_requi
});
}

@Test
public void it_throws_when_program_argument_is_not_present() {
Throwable ex = assertThrows(CommandLineArgumentException.class, () -> {
ArgumentHandler argumentHandler = new ArgumentHandler(new String[] { },
optionSpec);
argumentHandler.loadArgProgramPaths();
});
assertEquals("ERR030: Command line missing program argument.",
ex.getMessage());
}

}

0 comments on commit 1fa8b5b

Please sign in to comment.