NPE试图读取cucumber-jvm(黄瓜 - clojure)中的表格数据

时间:2012-03-08 18:28:09

标签: clojure cucumber

在我的功能文件中,我有类似的内容:

  Scenario: Things
    Given the table is empty
    When I add a thing:
      |          Foo  |    Bar |      Baz |
      | 1293883200000 | 123.45 |   123456 |
      | 1293884100000 | 123.45 |   123456 |

有什么想法吗?做错了?黄瓜-jvm中的错误?

它匹配我的步骤定义,但在实际执行其中的代码之前,我得到一个空指针异常:

java.lang.NullPointerException
    at cucumber.runtime.StepDefinitionMatch.getGenericListType(StepDefinitionMatch.java:144)
    at cucumber.runtime.StepDefinitionMatch.tableArgument(StepDefinitionMatch.java:135)
    at cucumber.runtime.StepDefinitionMatch.transformedArgs(StepDefinitionMatch.java:103)
    at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:43)
    at cucumber.runtime.Runtime.runStep(Runtime.java:220)
    at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
    at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
    at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:32)
    at cucumber.runtime.Runtime.run(Runtime.java:101)
    at cucumber.runtime.Runtime.run(Runtime.java:85)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:92)
    at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:30)
    at leiningen.cucumber.util$run_cucumber_BANG_.invoke(util.clj:48)
    at user$eval43.invoke(NO_SOURCE_FILE:1)
    at clojure.lang.Compiler.eval(Compiler.java:6465)
    at clojure.lang.Compiler.eval(Compiler.java:6455)
    at clojure.lang.Compiler.eval(Compiler.java:6431)
    at clojure.core$eval.invoke(core.clj:2795)
    at clojure.main$eval_opt.invoke(main.clj:296)
    at clojure.main$initialize.invoke(main.clj:315)
    at clojure.main$null_opt.invoke(main.clj:348)
    at clojure.main$main.doInvoke(main.clj:426)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:405)
    at clojure.lang.AFn.applyToHelper(AFn.java:163)
    at clojure.lang.Var.applyTo(Var.java:518)
    at clojure.main.main(main.java:37)
    at ✽.When I add a thing:(api.feature:9)

1 个答案:

答案 0 :(得分:3)

cucumber.runtime.StepDefinitionMatch中的getGenericListType(int)调用StepDefinition#getParameterTypes()看起来像cucumber.runtime.clojure.ClojureStepDefinition#getParameterTypes()中的错误,后者反过来引用null

不幸的是,{{1}} code that deals with tabular data {{1}}因此导致了NPE。

我提交了always returns指向这个问题。