void (Pair<TextValidationFunction, String> validatorWithId, String inputString, boolean shouldPassValidation, String comment) { String validationErrorMessage = validatorWithId.first.checkText(inputString); if (shouldPassValidation != (validationErrorMessage == null)) { StringBuilder testReport = new StringBuilder(); testReport.append("Input string: \"").append(inputString).append("\"") .append("\nValidator: ").append(validatorWithId.second) .append("\nExpected validation result: ").append(shouldPassValidation) .append("\nCurrent validation result: ").append(validationErrorMessage == null); if (validationErrorMessage != null) { testReport.append("\nValidation error message: ").append(validationErrorMessage); } if (comment != null) { testReport.append("\nTest comment: ").append(comment); } fail(testReport.toString()); } }