首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用cucumber-java在intellij 13.1.4中为android项目设置和运行cucumber bdd测试

如何使用cucumber-java在intellij 13.1.4中为android项目设置和运行cucumber bdd测试
EN

Stack Overflow用户
提问于 2014-09-12 23:23:39
回答 1查看 2.4K关注 0票数 2

Intellij IDE本机支持cucumber。但问题是,我正试图在intellij 13.1.4IDE中的android项目上创建并运行黄瓜测试。经过大量的研究,我发现了this教程。但是在遵循它并运行我的测试之后,我得到了以下结果

代码语言:javascript
复制
Running tests
Test running 
startedTest 
running failed: Unable to find instrumentation info for: ComponentInfo{com.test.cucumbertest.apptest/cucumber.api.android.CucumberInstrumentation}
Empty test suite.

这是我的项目CucumberTest | app | libs | | cucumber-android-1.1.8.jar | cucumber-core-1.1.8.jar | cucumber-html-0.2.3.jar | cucumber-java-1.1.8.jar | gherkin-2.11.2.jar | junit-4.11.jar src | androidTest | | java | | com.test.cucumbertest.app | | MyStepsDefs.java | | RunTest.java | | testclass.feature | main | java | com.test.cucumbertest.app | MainActivity.java的结构

MyStepDefs.java

代码语言:javascript
复制
package com.test.cucumbertest.app;

import android.test.ActivityInstrumentationTestCase2;
import cucumber.api.PendingException;
import cucumber.api.java.en.Given;

public class MyStepDefs extends ActivityInstrumentationTestCase2<MainActivity>{
    public MyStepDefs() {
        super(MainActivity.class);
    }
    @Given("^I have lunch the app$")
    public void I_have_lunch_the_app() throws Throwable {
        // Express the Regexp above with the code you wish you had
        assertTrue(true);
    } 

}

RunTest.java:

代码语言:javascript
复制
package com.test.cucumbertest.app;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(format = {"pretty", "html:report"})
public class RunTest {

}

testclass.feature:

代码语言:javascript
复制
Feature: Test BDD
  Scenario: Scenario One
    Given I have lunch the app

我做错了什么?

这是我的AndroidManifest

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.test.cucumbertest.app" >

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.test.cucumbertest.app.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

我正在使用gradle

EN

回答 1

Stack Overflow用户

发布于 2014-12-31 17:48:35

我收到了与您提供的信息类似的提示。不同的是我使用的是Android Studio。您可以尝试通过以下方式将检测标记添加到AndroidManifest.xml中

代码语言:javascript
复制
<instrumentation
        android:name="cucumber.api.android.CucumberInstrumentation"
        android:targetPackage="com.test.cucumbertest.app"
/>

但是,我猜你的帖子里有拼写错误??("com.test.cucumbertest.apptest“=> "com.test.cucumbertest.app.test")

如果仍然提示错误,您可能还需要将测试包重命名为"com.test.cucumbertest.app.test“

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25811672

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档