CLI switch cucumber.api.cli.Main cannot find step definitions

Problem
Cucumber cannot find the definition of the step when running with the CLI runner, but it can find it when running with the junit runner.

That is, when running cucumber-jvm from the linux command line, a function file was found, but the step description file was not found, creating a message,
"Undefined scenarios: src/test/java/com/logic/testing/ClassifyDocuments.feature:8"


(See below for the full message)

However, working through Maven eg. 'mvn test', step definitions were found and the test runs as expected. I have already covered similar questions ad nauseum and would appreciate any help before I go bald.
- Is it necessary to create files differently, eg. using a resource directory?
- Is the com.logic.testing glue parameter wrong?
- Is there a problem with the classpath?

More details
Here the command line operator is issued, located in the "autotest" folder:
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

The code is organized like this:
auto-test /
  SRC / test / Java
    com.logic.testing
      StepDefinitions.java
      ClassifyDocuments.feature
  SRC / Main / Java
    com.logic.testing AutoTestController.java (contains the class referenced by StepDefinitions.java)
  target / test-classes / com / logic / testing /
    StepDefinitions.class
  target / classes / com / logic / testing /
    AutoTestController.class

Inside / usr / local / bin / oucumber / there is:
cucumber core-1.2.5.jar
cucumber java-1.2.5.jar
cucumber-Deps JVM-1.05.jar
gherkins-2.12.2.jar

ClassifyDocuments.feature file:

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

      

StepDefinitions.java file:

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 after executing command line instruction (yes, it starts with "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();
}

      

+3


source to share


2 answers


Cucumbers skim the classpath for glue.



So, looking at the look, I would say yours -cp

is wrong. When running from, auto-test

I expect it to include ./target/classes/

its descendants as well, and then .

.

0


source


I have downloaded cucumber-core.jar to c: \ cukes folder and my test classes are in target / test-classes folder as I am using maven. also my maven dependencies are in the .m2 folder of my profile. below command line code works fine for me.

java -cp "c:/cukes/*;./../../.m2/*;target/test-classes" cucumber.api.cli.Main --glue "stepdefinitions" src/test/resources/features/sample.feature

      



I guess the problem is due to the classpath, try the following

java -cp "/usr/local/bin/cucumber/*;target/test-classes;target/classes" cucumber.api.cli.Main -g "com.logic.testing" src/test/java/com/logic/testing/

      

+1


source







All Articles