Problema
Cucumber no puede encontrar definiciones de pasos cuando se ejecuta con un corredor CLI, pero puede encontrarlo cuando se ejecuta con el corredor junit.
Es decir, cuando se ejecuta cucumber-jvm desde una línea de comandos de linux, se encuentra el archivo de características, pero no se encuentra el archivo de definiciones de pasos, produciendo el mensaje, "Undefined scenarios: src/test/java/com/logic/testing/ClassifyDocuments.feature:8"
(Ver abajo para el mensaje completo)
Sin embargo, ejecutándose a través de Maven, por ejemplo, 'prueba mvn', se encuentran las definiciones de los pasos y la prueba se ejecuta como se esperaba. Ya he revisado preguntas similares hasta la náusea y agradecería cualquier ayuda antes de quedarme calvo.
- ¿Los archivos deben estar organizados de manera diferente, por ejemplo, utilizando un directorio de 'recursos'?
- ¿El parámetro de cola, com.logic.testing, no es correcto?
- ¿Hay algún problema con el classpath?
Detalles
Aquí está la instrucción de línea de comando que se emite mientras está en la carpeta 'prueba automática':java -cp "/usr/local/bin/cucumber/cucumber-core-1.2.5.jar:/usr/local/bin/cucumber/*:." cucumber.api.cli.Main -g com.logic.testing src/test/java/com/logic/testing/ClassifyDocuments.feature -s
El código se organiza así:
auto-test /
src / test / java
com.logic.testing
StepDefinitions.java
ClassifyDocuments.feature
src / main / java
com.logic.testing
AutoTestController.java (contiene una clase a la que hace referencia StepDefinitions.java )
target / test-classes / com / logic / testing /
StepDefinitions.class
target / classes / com / logic / testing /
AutoTestController.class
Dentro de / usr / local / bin / cucumber / se encuentra:
cucumber-core-1.2.5.jar
cucumber-java-1.2.5.jar
cucumber-jvm-deps-1.05.jar
gherkin-2.12.2.jar
Archivo ClassifyDocuments.feature:
Feature: Classify documents in a package
As an auditor
I want to use software
So that I don't have to manually identify subdocuments
Scenario: execute workflow case2 test
Given the workflow case2 test can be configured
And I have been authenticated
When two jobs are submitted with different SLA duration
And the jobs are processed
Then the packages with the shorter SLA duration are completed first
Archivo StepDefinitions.java:
package com.logic.testing;
import java.io.File;
import org.junit.Assert;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class StepDefinitions {
AutoTestController atc;
@Given("^the workflow case2 test can be configured$")
public void the_workflow_case2_test_can_be_configured() throws Throwable {
atc = new AutoTestController();
atc.log("~Looking for configuration", log_src);
Assert.assertTrue(atc.getAutoTestConfig("workflow_case2"));
}
@When("^two jobs are submitted with different SLA duration$")
public void two_jobs_are_submitted_with_different_SLA_duration() throws Throwable {
Assert.assertTrue(atc.two_jobs_are_submitted_with_different_SLA_duration());
}
@And("^the jobs are processed$")
public void the_jobs_are_processed() throws Throwable {
Assert.assertTrue(atc.processJobs());
}
@Then("^the packages with the shorter SLA duration are completed first$")
public void the_packages_with_the_shorter_SLA_duration_are_completed_first() throws Throwable {
Assert.assertTrue(atc.checkPackageCompletionTimes("QC_CLASSIFICATION", "READY", 10, 300));
}
}
Error devuelto después de ejecutar la instrucción de línea de comando (sí, comienza con 'UUUUU'):
UUUUU
Undefined scenarios:
src/test/java/com/logic/testing/ClassifyDocuments.feature:8 # Scenario: execute workflow case2 test
1 Scenarios (1 undefined)
5 Steps (5 undefined)
0m0.000s
You can implement missing steps with the snippets below:
@Given("^the workflow case(\\d+) test can be configured$")
public void the_workflow_case_test_can_be_configured(int arg1) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Given("^I have been authenticated$")
public void i_have_been_authenticated() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@When("^two jobs are submitted with different SLA duration$")
public void two_jobs_are_submitted_with_different_SLA_duration() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@When("^the jobs are processed$")
public void the_jobs_are_processed() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Then("^the packages with the shorter SLA duration are completed first$")
public void the_packages_with_the_shorter_SLA_duration_are_completed_first() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
Pepino escanea el camino de la clase en busca de pegamento.
Mirando un vistazo, diría que estás -cp
equivocado. Cuando se ejecuta desde auto-test
, esperaría que incluyera ./target/classes/
y su descendiente en lugar de entonces .
.
Este artículo se recopila de Internet, indique la fuente cuando se vuelva a imprimir.
En caso de infracción, por favor [email protected] Eliminar
Déjame decir algunas palabras