/** Handle a spec that looks like package.className#methodName */ public void addMethod(String specString) throws SpecException { String[] results = specString.split("#"); if (results.length != 2) { throw new SpecException(specString, "Expected only one # in spec"); } String className = results[0]; String methodName = results[1]; Spec spec = getOrCreateSpec(className, specString); boolean found = false; for (Method clazzMethod : spec.getSpecClass().getMethods()) { if (clazzMethod.getName().equals(methodName)) { found = true; break; } } if (!found) { throw new SpecException( specString, String.format("Method %s not found in class %s", methodName, className)); } spec.addMethod(methodName); }