как исправить ошибку плагина maven surefire [произошла ошибка в разветвленном процессе]? - PullRequest
0 голосов
/ 26 марта 2019

Я пытаюсь запустить мой пример проекта, который использует Maven-testNG-cucumber, и развернуть его с помощью Docker. вот мой Dockerfile

FROM    maven:3.6.0-jdk-8
RUN     mkdir /docker
WORKDIR /docker
COPY    pom.xml .
COPY    testng.xml .
COPY    src .
RUN     mvn clean verify 

pom.xml

    <dependencies>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>1.2.5</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-jvm-deps</artifactId>
        <version>1.0.5</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-testng</artifactId>
        <version>1.2.5</version>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.9.8</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>net.masterthought</groupId>
        <artifactId>cucumber-reporting</artifactId>
        <version>3.8.0</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.44.0</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.4</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.20.1</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>testng.xml</suiteXmlFile>
                </suiteXmlFiles>
                <useSystemClassLoader>false</useSystemClassLoader>
            </configuration>
        </plugin>
        <plugin>
            <groupId>net.masterthought</groupId>
            <artifactId>maven-cucumber-reporting</artifactId>
            <version>3.8.0</version>
            <executions>
                <execution>
                    <id>execution</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <projectName>Sample</projectName>
                        <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>
Сценарий

выше работает вполне нормально, когда я запускаю проект локально, используя mvn verify . Затем я пытаюсь создать образ, используя docker build -t sample. . На этот раз я получил следующую ошибку.

 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20.1:test (default-test) on project Sample: There are test failures.
 [ERROR] Please refer to /docker/target/surefire-reports for the individual test results.

 [ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.

 [ERROR] There was an error in the forked process

 [ERROR] Cannot find class in classpath: TestRunner
 [ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process

 [ERROR] Cannot find class in classpath: TestRunner
 [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork
 (ForkStarter.java:673)
 [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork
 (ForkStarter.java:535)
 [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run 
 (ForkStarter.java:280)
 [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run
 (ForkStarter.java:245)
 [ERROR] at 
 org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider
 (AbstractSurefireMojo.java:1124)
 [ERROR]         at 
 org.apache.maven.plugin.surefire.AbstractSurefireMojo.
 executeAfterPreconditionsChecked(AbstractSurefireMojo.java:954)

Любая помощь будет высоко ценится

1 Ответ

0 голосов
/ 26 марта 2019

Учитывая, что вы храните testng.xml в src / test / resources (или укажите используемый вами путь), тогда я думаю, что вы должны упомянуть suiteXmlFile как

<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
...