我使用Green Coffee library在我的仪器测试中运行Cucumber场景。我跟着例如通过回购一步一步提供的,但这里的错误:类运行我的黄瓜场景时没有公共构造函数TestCase(String name)或TestCase()
junit.framework.AssertionFailedError: Class pi.survey.features.MembersFeatureTest has no public constructor TestCase(String name) or TestCase()
当我尝试默认的构造函数添加到类像provided here,它说
no default constructor available in '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'
有趣;你是对的; GreenCoffeeTest只有构造函数需要场景;所以似乎不可能扩展到具有默认构造函数或ctor取得字符串的类。 – GhostCat
是的,我创建了一个[问题](https://github.com/mauriciotogneri/green-coffee/issues/1)。那么GreenCoffeeTest类必须有默认的空构造函数或者什么? – getsadzeg
不知道。对我来说,这两件东西(GreenCoffee)和编号似乎根本就不能像现在一样与对方玩。 – GhostCat