5

Sto usando insieme Cucumber-JVM e Selenium WebDriver. Ho un progetto Maven in Eclipse e la dipendenza di file di pom.xml è come qui sotto:L'ultima versione di cetriolo-java e cetriolo-junit non funziona

<dependency> 
    <groupId>info.cukes</groupId> 
    <artifactId>cucumber-java</artifactId> 
    <version>1.2.2</version> 
    <scope>test</scope> 
</dependency> 
<dependency> 
    <groupId>info.cukes</groupId> 
    <artifactId>cucumber-junit</artifactId> 
    <version>1.2.2</version> 
    <scope>test</scope> 
</dependency> 

Il contenuto del file di RunCukesTest.java è:

import org.junit.runner.RunWith; 
import cucumber.junit.Cucumber; 
@RunWith(Cucumber.class) 
@Cucumber.Options(format = {"pretty", "html:target/cucumber-htmlreport","json-pretty:target/cucumber-report.json"}) 
public class RunCukesTest { 
} 

sto ottenendo l'errore nelle righe seguenti codice:

import cucumber.junit.Cucumber; 
@RunWith(Cucumber.class) 
@Cucumber.Options(format = {"pretty", "html:target/cucumber-htmlreport","json-pretty:target/cucumber-report.json"}) 

Ma quando ho usato la versione 1.0.14 funziona bene. Cosa c'è di sbagliato con l'ultima versione?

+0

quello messaggio di errore avete? – Paizo

+0

L'importazione cucumber.junit non può essere risolta per "import cucumber.junit.Cucumber;" e Marcatori multipli su questa linea \t - Cetriolo non può essere risolto su un tipo \t - La classe non può essere risolta per le prossime 2 righe di codice –

risposta

5

L'annotazione è cambiato @CucumberOptions:

E penso json-pretty è cambiato a json in questa versione cetriolo.

Questo dovrebbe funzionare:

@CucumberOptions(
     format = {"pretty", "html:target/cucumber-htmlreport","json:target/cucumber-report.json"} 
) 

Inoltre, secondo il formato cucumber-jvm specifications è obsoleto. Sostituire con plugin. Questo dovrebbe funzionare anche:

plugin = {"pretty", "html:target/cucumber-htmlreport","json:target/cucumber-report.json"} 

Speranza che aiuta

8

@Cucumber.Options è deprecated uso @CucumberOptions invece

@CucumberOptions(
    format = "pretty", 
    features = "//refer to Feature file" 
) 

Spero che questo ti aiuta

3

con cetriolo 1.2.2

<cucumber.version>1.2.2</cucumber.version> 
.... 
    <dependency> 
     <groupId>info.cukes</groupId> 
     <artifactId>cucumber-java</artifactId> 
     <version>${cucumber.version}</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>info.cukes</groupId> 
     <artifactId>cucumber-junit</artifactId> 
     <version>${cucumber.version}</version> 
     <scope>test</scope> 
    </dependency> 
.... 
Test di lavoro

qui un esempio:

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

@RunWith(Cucumber.class) 
@CucumberOptions(features = "classpath:features/myfeature.feature", tags = "@Mytag", plugin = {"pretty", "html:target/cucumber"}) 
public class MYAcceptanceTest { 

} 

nota l'importazione è cucumber.api.junit.Cucumber invece di cucumber.junit.Cucumber ed è necessario aggiungere l'importazione per le opzioni di cetriolo. Lo stereotipo per l'opzione è @CucumberOptions anziché @Cucumber.Options

1

È possibile provare a inserire sia il file RunCukesTest.java che il file di funzionalità nella stessa cartella o pacchetto.

1

sostituire @ Cucumber.Options con @CucumberOptions e formato con Plugin

@CucumberOptions(plugin = {"pretty", "html:target/cucumber-htmlreport","json-pretty:target/cucumber-report.json"}) 
public class RunCukesTest { 
} 
+0

Altre risposte già descrivono esattamente questi stessi passaggi. – Pyves

1

versione cetriolo è stato aggiornato alla versione 2.0.1. Sostituire

<groupId>info.cukes</groupId> 

con

<groupId>io.cucumber</groupId> 
Problemi correlati