Выполнение Cucmber Feature file из Maven CLI - PullRequest
0 голосов
/ 14 марта 2019

Я пытаюсь выполнить файл функций огурца из командной строки maven и столкнулся со следующей проблемой - Не удалось выполнить цель org.apache.maven.plugins: maven-surefire-plugin: 2.14.1: test (default-test)в проекте Maven: тесты не выполнялись!

Команда, которую я использовал для выполнения, - - mvn -Dtest -Document.options = "src / test / resources / maven_poc / excel_colors.feature: 3"

Однако файл определений шагов успешно выполняется при запуске из командной строки maven.• mvn -Dtest = excel_color_stepdef test Снимок экрана по ссылке - https://i.stack.imgur.com/MKsd8.jpg

Мой файл 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/xsd/maven-4.0.0.xsd">
  
  <modelVersion>4.0.0</modelVersion>

  <groupId>Cucumber_POC</groupId>
  <artifactId>Maven</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

 <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  
<reporting>
   <plugins>
      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-jxr-plugin</artifactId>
         <version>2.3</version>
      </plugin>
   </plugins>
</reporting>
  
 <build>
	<defaultGoal>install</defaultGoal>
        <pluginManagement>
      		<plugins>
         		<plugin>
    			<groupId>org.apache.maven.plugins</groupId>
    			<artifactId>maven-surefire-plugin</artifactId>
   	 			<version>2.14.1</version>
    			<configuration>
        		<testFailureIgnore>true</testFailureIgnore>
        		</configuration>
				</plugin>  
				
		 		<plugin>
        		<groupId>org.apache.maven.plugins</groupId>
        		<artifactId>maven-install-plugin</artifactId>
       			<version>2.5.2</version>
 				</plugin>
 				
 				<plugin>
        		<groupId>org.apache.maven.plugins</groupId>
        		<artifactId>maven-jar-plugin</artifactId>
        		<version>2.4</version>
        		</plugin>
        		
        		<plugin>
  				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-site-plugin</artifactId>
  				<version>3.7.1</version>
				</plugin>
				
				<plugin>
  				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-project-info-reports-plugin</artifactId>
  				<version>3.0.0</version>
				</plugin>
				
		</plugins>
    </pluginManagement>      
</build>
		
  <dependencies>
   	
   	 	<dependency>
      	<groupId>junit</groupId>
      	<artifactId>junit</artifactId>
      	<version>4.12</version>
      	<scope>test</scope>
     	</dependency>
    
      	<dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>2.3.1</version>
        <scope>test</scope>
    	</dependency>
    
      	<dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>2.3.1</version>
        <scope>test</scope>
    	</dependency>
    
    	<dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>gherkin</artifactId>
        <version>5.1.0</version>
        <scope>test</scope>
    	</dependency>
    
     	<dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-core</artifactId>
        <version>2.3.1</version>
        </dependency>

		<dependency>
		<groupId>org.apache.poi</groupId>
		<artifactId>poi</artifactId>
		<version>4.0.1</version>
		</dependency>

		<dependency>
    	<groupId>org.apache.poi</groupId>
    	<artifactId>poi-ooxml</artifactId>
    	<version>4.0.1</version>
		</dependency>
        
		<dependency>
    	<groupId>org.apache.maven.plugins</groupId>
    	<artifactId>maven-surefire-plugin</artifactId>
    	<version>2.12.4</version>
  		</dependency>

		 <dependency>
         <groupId>org.junit.platform</groupId>
         <artifactId>junit-platform-surefire-provider</artifactId>
         <version>1.1.0</version>
         </dependency>
     
             
 </dependencies>
 
</project>

Ответы [ 2 ]

2 голосов
/ 15 марта 2019

Они не похожи на действительные команды maven.Это mvn test.И системное свойство называется cucumber.options.Итак mvn test -Dcucumber.options="src/test/resources/maven_poc/excel_colors.feature:3"

0 голосов
/ 16 марта 2019

Вы должны выполнить тестовый класс java, который ссылается на огурец.Что-то вроде:

@ContextConfiguration(loader = SpringBootContextLoader.class, classes = EligibilityApplication.class)
@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/resources/cucumber/eligibility/listpolicies/ListPolicies.feature", strict = true)
public class ListPoliciesTest {

}

И в команде maven вы будете использовать что-то вроде:

mvn -Dtest="src/test/java/../ListPoliciesTest.java"
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...