Получение не найдено функций в classpath: предупреждение бегунов после интеграции с testNG - PullRequest
0 голосов
/ 05 марта 2020

Когда я пытался запустить скрипт с TestNGCucumberRunner, я получаю не найдена функция в classpath: предупреждение о бегунах . Но когда я запускал его с помощью JUnit (без testNG), он работал нормально. Какие изменения мне нужно внести в мой код? Я пытался использовать последнюю версию Cucumber; это дает мне некоторую ошибку для CucumberFeatureWrapper, поскольку она не определена.

pom. xml файл:

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <selenium.version>3.141.59</selenium.version>
        <testng.version>7.0.0</testng.version>
        <junit.version>4.12</junit.version>
        <java.version>1.8</java.version>
        <cucumber.version>4.7.2</cucumber.version>
        <maven.compiler.version>3.8.1</maven.compiler.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

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


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

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

        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>4.7.2</version>
            <!-- <scope>test</scope> -->
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-testng -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-testng</artifactId>
            <version>4.7.2</version>
            <scope>compile</scope> 
            <exclusions>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

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

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>4.7.2</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-jvm-deps</artifactId>
            <version>1.0.6</version>
            <!-- <scope>provided</scope> -->
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-picocontainer -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>4.7.2</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/com.github.mkolisnyk/cucumber-runner -->
        <dependency>
            <groupId>com.github.mkolisnyk</groupId>
            <artifactId>cucumber-runner</artifactId>
            <version>1.0.8</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.github.mkolisnyk/cucumber-reports -->
        <dependency>
            <groupId>com.github.mkolisnyk</groupId>
            <artifactId>cucumber-reports</artifactId>
            <version>1.3.5</version>
            <type>pom</type>
        </dependency>

        <!-- https://mvnrepository.com/artifact/net.masterthought/cucumber-reporting -->
        <dependency>
            <groupId>net.masterthought</groupId>
            <artifactId>cucumber-reporting</artifactId>
            <version>5.1.1</version>
            <!--<scope>test</scope> -->
        </dependency>


    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M3</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
            <plugin>
                <groupId>net.masterthought</groupId>
                <artifactId>maven-cucumber-reporting</artifactId>
                <version>5.1.1</version>
                <executions>
                    <execution>
                        <id>execution</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>target/cucumber-reports/advanced-reports</outputDirectory>
                            <cucumberOutput>target/cucumber-reports/CucumberTestReport.json</cucumberOutput>
                            <buildNumber>1</buildNumber>
                            <parallelTesting>false</parallelTesting>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

класс бегуна для моего проекта, который находится в каталоге src / test / java:

@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/resources/functionalTests", 
glue = {"stepDefinitions"}, 
tags = {"@SmokeTest"}, 
plugin = {
        "pretty", "html:target/site/cucumber-pretty", 
        "json:target/cucumber-reports/CucumberTestReport.json" }, monochrome = true)

public class RunnerTest {
    private TestNGCucumberRunner testNGCucumberRunner;

    @BeforeClass(alwaysRun = true)
    public void setUpClass() throws Exception {     
        testNGCucumberRunner = new TestNGCucumberRunner(this.getClass());
    }

@Test(dataProvider = "features")    
public void feature(PickleEventWrapper eventwrapper,CucumberFeatureWrapper cucumberFeature) throws Throwable {
    //testNGCucumberRunner.runCucumber(cucumberFeature.getCucumberFeature());
    testNGCucumberRunner.runScenario(eventwrapper.getPickleEvent());

}

       @DataProvider//(parallel=true)
        public Object[][] features() {
           // return testNGCucumberRunner.provideFeatures();        
             return testNGCucumberRunner.provideScenarios();
        }

        @AfterClass(alwaysRun = true)
        public void tearDownClass() throws Exception {      
            testNGCucumberRunner.finish();        
        }

Также, Я приложил структуру папок:

Folder structure

Ответы [ 2 ]

0 голосов
/ 10 марта 2020

Возникла проблема с моим проектом maven, однажды после того, как я очистил проект и обновил все работало нормально.

0 голосов
/ 05 марта 2020

Afaik вы можете запустить Cucumber с либо JUnit или TestNG, но не обоими. Так что это может быть проблемой. Я не знаком с TestNG, поэтому не могу вам помочь.

Кроме того, я не знаю, что вы подразумеваете под "когда я работаю с JUnit (без TestNG)"; чем ты занимаешься? (поскольку у вас есть TestNG в вашем коде).

Кроме того, я вижу, что у вас есть явно определенные зависимости, которые являются транзитивными зависимостями для Cucumber. Проверьте Cucumber docs на наличие необходимых вам зависимостей.

В вашем конкретном случае: * Удалите следующие зависимости от Cucumber cucumber-core и cucumber-jvm-deps * Удалите junit и cucumber-junit, если Вы хотите запустить с TestNG

Наконец, я вижу, что у вас есть com.github.mkolisnyk: cucumber-runner - что это делает? Тебе это нужно? И у вас есть 2 разных репортера (com.github.mkolisnyk:cucumber-reports и net.masterthought:cucumber-reporting); Вы можете выбрать только один.

Удачи!

...