/core/src/main/java/cucumber/runtime/StepDefinition.java

https://github.com/eivindingebrigtsen/cucumber-jvm · Java · 49 lines · 13 code · 8 blank · 28 comment · 0 complexity · 96e09b356e96bd0250013bcd9ea90bab MD5 · raw file

  1. package cucumber.runtime;
  2. import gherkin.formatter.Argument;
  3. import gherkin.formatter.model.Step;
  4. import java.lang.reflect.Type;
  5. import java.util.List;
  6. public interface StepDefinition {
  7. /**
  8. * Returns a list of arguments. Return null if the step definition
  9. * doesn't match at all. Return an empty List if it matches with 0 arguments
  10. * and bigger sizes if it matches several.
  11. */
  12. List<Argument> matchedArguments(Step step);
  13. /**
  14. * The source line where the step definition is defined.
  15. * Example: foo/bar/Zap.brainfuck:42
  16. */
  17. String getLocation();
  18. /**
  19. * The parameter types this step definition can be invoked with.
  20. * This will be used to coerce string values from arguments before
  21. * invoking the step definition. The size of the returned array
  22. * must be equal to the number of arguments accepted by execute.
  23. * <p/>
  24. * If the parameter types are unknown at runtime, the result may be null.
  25. */
  26. List<ParameterType> getParameterTypes();
  27. /**
  28. * Invokes the step definition. The method should raise a Throwable
  29. * if the invocation fails, which will cause the step to fail.
  30. */
  31. void execute(Object[] args) throws Throwable;
  32. /**
  33. * Return true if this matches the location. This is used to filter
  34. * stack traces.
  35. */
  36. boolean isDefinedAt(StackTraceElement stackTraceElement); // TODO: redundant with getLocation?
  37. /**
  38. * @return the pattern associated with this instance. Used for error reporting only.
  39. */
  40. String getPattern();
  41. }