使用Cucumber - Java编写inTestRunner类时出现语法错误

时间:2017-03-09 10:56:10

标签: cucumber

问题:使用黄瓜jvm类的TestRunner获取语法错误:     黄瓜设置完成。我运行了cucrunner类并且选择了特征文件并且运行给了我错误以添加缺少的实现。但是当我添加具有详细方法的类时。我得到语法错误。无法理解错误:     错误如下:

Scenario: Login
Given user is on home page
When user navigates in home page
And user enters '<Username>' and '<Password>'
Then Message displayed as successful

|Username | Password |
| triptitest | sleep345|

下面的功能文件 功能:计算器

import cucumber.api.junit.Cucumber;
import cucumber.api.CucumberOptions;

@RunWith(Cucumber.class)
@CucumberOptions(
        glue = "stepdefinition"
        ,features = "Feature/calculator.feature"
        )

public class cucumberunner {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

    }

}


POM xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.xxxxxx.bdd</groupId>
  <artifactId>cucumber-test</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>XXXXX</name>
  <url>XXXXX</url>
  <dependencies>
            <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.2.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.2.5</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>    
  </dependencies>
   <build>
        <plugins>
            <plugin>
                <artifactId>
                    maven-compiler-plugin
                </artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

黄瓜文件     import org.junit.runner.RunWith;

import cucumber.api.PendingException;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.*;

public class stepdefinition_test {

    public static void main(String[] args) {

        @Given("^user is on home page$")
        public void user_is_on_home_page() throws Throwable {
            // Write code here that turns the phrase above into concrete actions
            throw new PendingException();
        }

        @When("^user navigates in home page$")
        public void user_navigates_in_home_page() throws Throwable {
            // Write code here that turns the phrase above into concrete actions
            throw new PendingException();
        }

        @When("^user enters '<Username>' and '<Password>'$")
        public void user_enters_Username_and_Password() throws Throwable {
            // Write code here that turns the phrase above into concrete actions
            throw new PendingException();
        }

        @Then("^Message displayed as successful$")
        public void message_displayed_as_successful() throws Throwable {
            // Write code here that turns the phrase above into concrete actions
            // For automatic transformation, change DataTable to one of
            // List<YourType>, List<List<E>>, List<Map<K,V>> or Map<K,V>.
            // E,K,V must be a scalar (String, Integer, Date, enum etc)
            throw new PendingException();
        }

    }

}

Testrunner文件     包stepdefinition;

var contours = L.tileLayer.wms('http://gis01-dbn:8080/geoserver/Inyaninga_243-198/wms', {
            layers: 'Inyaninga_243-198:contours_3857',
            format: 'image/png',
            transparent: true,
        });

contours.setParams({CQL_FILTER:"elevation = 100"});

0 个答案:

没有答案