簡體   English   中英

Cucumber-jvm指定的參數與以下任何構造函數都不匹配:[private java.lang.Class()];

[英]Cucumber-jvm Either the specified parameters do not match any of the following constructors: [private java.lang.Class()];

我正在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
  • 搖籃:2.2.1
  • 黃瓜:1.2.0
  • 意式濃縮咖啡:2.0

我想通了。 此構造函數正在觸發錯誤。

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

我更改為后,錯誤消失了

public TestActivitySteps(TestActivity activityClass) {
    super(activityClass);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM