Fixed bug where -getSnippet in clj.clj received only the step parameter. #650

Merged
merged 1 commit into from Jan 26, 2014

Projects

None yet

3 participants

@shaolang
Contributor

cucumber.runtime.UndefinedStepsTracker actually calls the Backend
instances with 2 parameters--Step and FunctionNameGenerator--but
Clojure's Backend implementation only accepts one.

Instead of testing generation of Clojure Snippet with a test-only
ClojureSnippet instance, ClojureSnippetTest now tests the real
implementation in clj.clj.

Prior this fix, cucumber-clojure throws the following exceptions:

Exception in thread "main" clojure.lang.ArityException: Wrong number of args (3) passed to: clj$-getSnippet
        at clojure.lang.AFn.throwArity(AFn.java:437)
        at clojure.lang.AFn.invoke(AFn.java:47)
        at cucumber.runtime.clj.Backend.getSnippet(Unknown Source)
        at cucumber.runtime.UndefinedStepsTracker.getSnippets(UndefinedStepsTracker.java:32)
        at cucumber.runtime.Runtime.getSnippets(Runtime.java:183)
        at cucumber.runtime.snippets.SummaryPrinter.printSnippets(SummaryPrinter.java:33)
        at cucumber.runtime.snippets.SummaryPrinter.print(SummaryPrinter.java:18)
        at cucumber.runtime.Runtime.printSummary(Runtime.java:125)
        at cucumber.runtime.Runtime.run(Runtime.java:114)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
@shaolang shaolang Fixed bug where -getSnippet in clj.clj received only the step parameter.
cucumber.runtime.UndefinedStepsTracker actually calls the Backend
instances with 2 parameters--Step and FunctionNameGenerator--but
Clojure's Backend implementation only accepts one.

Instead of testing generation of Clojure Snippet with a test-only
ClojureSnippet instance, ClojureSnippetTest now tests the real
implementation in clj.clj.
5e3d2fd
Contributor

@aslakhellesoy I have checked this PR and think it is OK to merge (and at the same time remove the now obsolete comment about keeping the snippet templates in clj.clj and the removed ClojureSnippet.java in sync).

  • The getSnippet function of the Clojure Backend needs to conform to the signature of the Backend interface in core (even though the FunctionNameGenerator argument is not used, since Clojure step definitions does not have a function name separate from the step definition regexp).
  • Testing the generated snippets in isolation using a copy of the snippet template in ClojureSnippet is faster (~0.3s instead of ~3s), but testing a copy instead of the real thing also has problems (including hiding this bug), so the solution is the PR seems like an improvement to me.

OK?

Owner

Ok - go ahead and merge!

@brasmusson brasmusson added a commit that referenced this pull request Jan 26, 2014
@brasmusson brasmusson Merge #650. Update History.md
Also remove obsolete comment from the Clojure backend.
63dca60
@brasmusson brasmusson merged commit 5e3d2fd into cucumber:master Jan 26, 2014

1 check passed

default The Travis CI build passed
Details
Contributor

Merged. Thanks for your contribution @shaolang.

Contributor

@brasmusson You're welcome. :)

@shaolang shaolang deleted the shaolang:clojure-get-snippet-fix branch Mar 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment