1

我正在 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()));
    }
}

笔记:

  • 安卓工作室:1.0.2
  • 摇篮:2.2.1
  • 黄瓜:1.2.0
  • 浓缩咖啡:2.0
4

1 回答 1

2

我想通了。此构造函数触发了错误。

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

我更改为后错误消失了

public TestActivitySteps(TestActivity activityClass) {
    super(activityClass);
}
于 2015-01-28T01:34:29.517 回答