Maven+eclipse+Java+cucumber test framework is a way of running tests

First go to the Pom file part, which is the startup program part. (There are many explanations on the Internet about the function of each label. I will not repeat it here, only the meaning of the labels used) The picture is as follows:

<profiles>
<profile>
<id>run</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
<configuration>
<includes>
<include>**/RunTest.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

                                                                     Code 1.1

The function of the maven-surefire-plugin plugin is to select the test class (multiple can be specified) in the <include>...</include> tag to perform the test when executing the test.


The program execution entry is as follows

@RunWith(Cucumber.class)
@CucumberOptions(
format = {"pretty"},
 features = {"src/test/resources/feature/BaiDu.feature"}
, glue = {"lsy.auto.web.test.steps"},
   dryRun = false


)
public class RunTest {


}

   Code 1.2

The RunTest class is the test class to be executed in the <include>...</include> tag in Code 1.1.

The feature keyword (personal habitual name) is used to specify the feature file to be run. If it is executed for multiple times, it is separated by commas (format: features={"feature file 1 path", "feature file 2 path", . ......}).

The glue keyword (personal habitual name) is used to specify the matching step JAVA file (that is, the so-called script) to be run. If multiple scripts are matched, separate them with commas (format: glue={“StepJava file 1” package name, "StepJava file 2 package name", ........}


Configure and run, as shown below


The name attribute, fill in at will, he is just a code name to start the maven project

base directory property, import the maven project you want to run

Goals attribute, fill in test

profiles attribute, fill in the characters in the <id>....</id> tag in Figure 1.1

Click "Run" to start the project successfully.




Such a simple Maven+eclipse+Java+cucumber project can be started! ! ! ! !


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324883845&siteId=291194637
Recommended