Cucumber-jvm指定的参数与以下任何构造函数都不匹配:[private java.lang.Class()];

时间:2015-01-27 21:57:16

标签: java android bdd cucumber-jvm picocontainer

我正在Android上测试一个简单的Cucumber BDD测试并获得黄瓜错误

org.picocontainer.PicoCompositionException: Either the specified 
parameters do not match any of the following constructors: [private 
java.lang.Class()]; OR the constructors were not accessible for 
'java.lang.Class'

我无法弄清楚这个错误来自哪里。 我错过了什么吗?

我的专题文件

Scenario Outline: Test scenario
    Given I have a TestActivity
    Then I should see <text> on the display

Examples:
    | text |
    | 123  |
    | test |

步骤定义

@CucumberOptions(features = "features", format = "pretty")
public class TestActivitySteps extends ActivityInstrumentationTestCase2<TestActivity> {

    public TestActivitySteps(Class<TestActivity> activityClass) {
        super(activityClass);
    }

    @Given("^I have a TestActivity$")
    public void I_have_a_TestActivity() {
        assertNotNull(getActivity());
    }

    @Then("^I should see (\\S+) on the display$")
    public void I_should_see_s_on_the_display(final String s) {
        onView(withText(s)).check(matches(isDisplayed()));
    }
}

注:

  • Android Studio:1.0.2
  • Gradle:2.2.1
  • 黄瓜:1.2.0
  • Espresso:2.0

1 个答案:

答案 0 :(得分:2)

我发现了。这个构造函数触发了错误。

public TestActivitySteps(Class<TestActivity> activityClass) {
    super(activityClass);
}

我改为

后错误消失了
public TestActivitySteps(TestActivity activityClass) {
    super(activityClass);
}