Как запустить тестовый бегун огурца с помощью командной строки junit - PullRequest
0 голосов
/ 06 мая 2020

У меня есть структура проекта ниже:

enter image description here

Я создал тест BDD с использованием Cucumber JUnit. Я хочу запустить этот тест как JUnit, используя командную строку

Test Runner:

package com.welcome.runner;

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

import org.junit.BeforeClass;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(tags = "@launch", features = "features", glue = {"com.welcome.steps"}, plugin = {"pretty", "json:target/cucumber.json"})
public class TestRunner {

    @BeforeClass
    public static void testMethod() {
        System.out.println("This is called before");
    }

}

И это зависимости в pom.xml

<dependencies>

    <!-- https://mvnrepository.com/artifact/junit/junit -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.13</version>
        <scope>test</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.testng/testng -->
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>7.0.0</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>${version.cucumber}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>${version.cucumber}</version>
        <scope>test</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>3.13.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.13.0</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/io.appium/java-client -->
    <dependency>
        <groupId>io.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>6.1.0</version>
    </dependency>

</dependencies>

Пока я пытаюсь выполнить класс TestRunner, используя команду ниже (переход в каталог проекта):

java -cp /Users/my.user/.m2/repository/junit/junit/4.13/junit-4.13.jar:hamcrest-core-2.2.jar:. org.junit.runner.JUnitCore com.welcome.runner.TestRunner

Я начал получать ошибку ниже:

1) initializationError (org.junit.runner.JUnitCommandLineParseResult) java .lang.IllegalArgumentException: не удалось найти класс [com.welcome.runner.TestRunner] в org.junit.runner.JUnitCommandLineParseResult.parseParameters (JUnitCommandLineParseResult. * В LineParseResult. java: 100 JUnitCommandLineParseResult. java: 50) в org.junit.runner.JUnitCommandLineParseResult.parse (JUnitCommandLineParseResult. java: 44) в org.junit.runner.JUnitCore: org.junit.runner.JUnitCore .runner.JUnitCore.main (JUnitCore. java: 36) Вызвано: java .lang.ClassNotFoundException: com.welcome.runner.TestRunner

Я не уверен, что здесь не так.

...