1

I am testing a simple Cucumber BDD test on Android and getting a cucumber error

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'

I cannot figure out where this error is coming from. Am I missing something ?

My feature file

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

Examples:
    | text |
    | 123  |
    | test |

Step definition

@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()));
    }
}

NOTE:

  • Android Studio: 1.0.2
  • Gradle: 2.2.1
  • Cucumber: 1.2.0
  • Espresso: 2.0
Emma
  • 8,518
  • 1
  • 18
  • 35

1 Answers1

2

I figured out. This constructor was triggering the error.

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

The error was gone after I changed to

public TestActivitySteps(TestActivity activityClass) {
    super(activityClass);
}
Emma
  • 8,518
  • 1
  • 18
  • 35