getsadzeg getsadzeg - 1 year ago 85
Android Question

Class has no public constructor TestCase(String name) or TestCase() while running my Cucumber scenario

I'm using Green Coffee library to run Cucumber scenarios in my instrumentation tests. I followed example provided by repo step-by-step, but here's the error:

junit.framework.AssertionFailedError: Class pi.survey.features.MembersFeatureTest has no public constructor TestCase(String name) or TestCase()


And when I try to add default constructor to the class like provided here, it says


no default constructor available in
'com.mauriciotogneri.greencoffee.GreenCoffeeTest'


Here's my test's source code:

package pi.survey.features;

import android.support.test.rule.ActivityTestRule;

import com.mauriciotogneri.greencoffee.GreenCoffeeConfig;
import com.mauriciotogneri.greencoffee.GreenCoffeeTest;
import com.mauriciotogneri.greencoffee.Scenario;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.io.IOException;

import pi.survey.MainActivity;
import pi.survey.steps.memberSteps;

@RunWith(Parameterized.class)
public class MembersFeatureTest extends GreenCoffeeTest {
@Rule
public ActivityTestRule<MainActivity> activity = new ActivityTestRule<>(MainActivity.class);

public MembersFeatureTest(Scenario scenario) {
super(scenario);
}



@Parameterized.Parameters
public static Iterable<Scenario> scenarios() throws IOException {
return new GreenCoffeeConfig()
.withFeatureFromAssets("assets/members.feature")
.scenarios();
}

@Test
public void test() {
start(new memberSteps());
}

}


And my
members.feature
source:

Feature: Inserting info to server



Scenario: Invalid members
When I introduce an invalid members
And I press the login button
Then I see an error message saying 'Invalid members'

Answer Source

Solved problem by just fixing the structure.

code details in this commit

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download