我正在使用Green Coffee 库在我的仪器测试中运行 Cucumber 场景。我按照 repo 一步一步提供的示例进行操作,但这是错误:
junit.framework.AssertionFailedError: Class pi.survey.features.MembersFeatureTest has no public constructor TestCase(String name) or TestCase()
当我尝试向这里提供的类添加默认构造函数时,它说
'com.mauriciotogneri.greencoffee.GreenCoffeeTest' 中没有可用的默认构造函数
这是我的测试源代码:
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());
}
}
我的members.feature
消息来源:
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'