Когда я пытаюсь:
java cucumber.api.cli.Main --help
Я получил:
Could not find or load main class cucumber.api.cli.Main
Мои конфигурации:
Я действительно не знаю, в чем проблема ... Мой тестовый запуск прошел успешно.
Я использую gradle и IntelliJ
Надеюсь, мне кто-нибудь поможет :)
------------редактировать-----------------
Мой build.gradle:
plugins {
id 'java'
}
group 'CucumberWithSeleniumTest'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile 'io.cucumber:cucumber-java:2.4.0'
testCompile 'io.cucumber:cucumber-junit:2.4.0'
compileOnly group: 'info.cukes', name: 'gherkin', version: '2.12.2'
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.5.3'
testCompile group: 'net.sourceforge.cobertura', name: 'cobertura', version: '2.1.1'
compile group: 'io.cucumber', name: 'cucumber-html', version: '0.2.7'
compileOnly group: 'io.cucumber', name: 'cucumber-jvm-deps', version: '1.0.6'
compile group: 'net.masterthought', name: 'cucumber-reporting', version: '4.2.2'
testCompile group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3'
}
configurations {
cucumberRuntime {
extendsFrom testRuntime
}
}
task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "cucumber.api.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['--plugin', 'pretty', '--glue', 'gradle.cucumber', 'src/test/resources']
}
}
}
И моя папка проекта:
--------------------------- edit2 ---------------------- Здесь:
C:\Users\...\CucumberWithSeleniumTest>gradle cucumber
Task :cucumber
Feature: Reset functionality on login page of Application
Scenario Outline: Verification of Reset button # src/test/resources/MyTest.feature:3
Given Open the Firefox and launch the application
When Enter the <username> and <password>
Then Reset the credential
Examples:
Scenario Outline: Verification of Reset button # src/test/resources/MyTest.feature:10
Given Open the Firefox and launch the application # null
When Enter the User1 and password1 # null
Then Reset the credential # null
Scenario Outline: Verification of Reset button # src/test/resources/MyTest.feature:11
Given Open the Firefox and launch the application # null
When Enter the User2 and password2 # null
Then Reset the credential # null
Scenario Outline: Verification of Reset button # src/test/resources/MyTest.feature:12
Given Open the Firefox and launch the application # null
When Enter the User3 and password3 # null
Then Reset the credential # null
3 Scenarios (3 undefined)
9 Steps (9 undefined)
0m0,019s
You can implement missing steps with the snippets below:
@Given("^Open the Firefox and launch the application$")
public void open_the_Firefox_and_launch_the_application() {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@When("^Enter the User(\\d+) and password(\\d+)$")
public void enter_the_User_and_password(int arg1, int arg2) {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Then("^Reset the credential$")
public void reset_the_credential() {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
BUILD SUCCESSFUL in 21s
3 actionable tasks: 2 executed, 1 up-to-date
Конечно, я редактирую свой вопрос
Вы пробовали запустить gradle cucumber?
Я делаю. Вы можете увидеть результат после --- edit2 ---
Когда вы выполняете java cucumber.api.cli.Main --help из интерфейса командной строки, вы также должны указать путь к классу. Вместо этого попробуйте указать в диалоговом окне аргумент программы --help.
только '--help'? Тогда я получаю: команда «--help» либо написана с ошибкой, либо не может быть найдена.
Пакет StepDefinition должен находиться под src/main/java.
Почему я никогда не делал этого bevor. (IntelliJ говорит: интерфейс cucumber.api.java.en. Когда, указанный в файле Steps.java, не будет доступен в модуле CucumberWithSeleniumTest_main Класс cucumber.api.PendingException, указанный в файле Steps.java, не будет доступен в модуле CucumberWithSeleniumTest_main Интерфейс cucumber.api.java.en.Given, указанный в файле Steps.java, не будет доступен в модуле CucumberWithSeleniumTest_main. Интерфейс cucumber.api.java.en. Тогда, указанный в файле Steps.java, будет недоступен в модуле CucumberWithSeleniumTest_main. )
Почему вы запускаете java cucumber.api.cli.Main вместо запуска класса RunTest?
@AlexanderTerekhov Понятно, но как я могу запустить это без junit ... Это не работает
Хорошо, вы хотите запустить его прямо с cucumber.api.cli.Main или просто запустить? Вы можете использовать первый ответ отсюда: stackoverflow.com/questions/16739347/… Вам нужно создать свою собственную оболочку класса и программно запустить из нее Cucumber.
Я предпочитаю напрямую: java cucumber.api.cli.Main --help




Хорошо, я обнаружил одну проблему, провожу тест с помощью junit
task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "cucumber.api.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['--plugin', 'pretty', '--glue', 'gradle.cucumber', 'src/test/resources']
}
}
}
Если я меняю: args = ['--plugin', 'pretty', '--glue', 'gradle.cucumber', 'src / test / resources'] на args = ['--help'], он работает
но без юнита понятия не имею
Не могли бы вы показать нам полную структуру папок вашего проекта?