无法在Jenkins中运行测试:测试运行:0,失败:0,错误:0,跳过:0

yyhrrdl8  于 2023-06-21  发布在  Jenkins
关注(0)|答案(1)|浏览(288)

我在Jenkins中执行我的Maven项目时遇到了一些问题。似乎没有找到测试用例。问题是我已经在我的pom中指定了文件夹。这是我的pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>                                                 
    <properties>
        <defaultTestListeners>false</defaultTestListeners>
        <suiteXml>testSuite.xml</suiteXml>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <build>
        <pluginManagement>
            <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-enforcer-plugin</artifactId>
                    <version>3.0.0-M3</version>
                    <executions>
                        <execution>
                            <id>enforce</id>
                            <configuration>
                                <rules>
                                    <dependencyConvergence/>
                                </rules>
                            </configuration>
                            <goals>
                                <goal>enforce</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M5</version>
                    <configuration>
                        <argLine>-Dfile.encoding=UTF-8</argLine>
                        <!--argLine>-Xmx2048m -Xms1024m -XX:MaxPermSize=512m</argLine-->
                        <testSourceDirectory>src/main/java/axn/tests</testSourceDirectory>
                        <testClassesDirectory>${project.build.directory}\classes\
                        </testClassesDirectory>
                        <suiteXmlFiles>
                            <suiteXmlFile>src/main/resources/suites/${suiteXml}</suiteXmlFile>
                        </suiteXmlFiles>
                        <includes>
                            <include>*/*Test.java</include>
                        </includes>
                        <properties>
                            <property>
                                <name>usedefaultlisteners</name>
                                <value>${defaultTestListeners}</value>
                            </property>
                            <!--property>
                                <name>listener</name>
                                <value>${listeners}</value>
                            </property-->
                        </properties>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <dependencies>
        <dependency>
            <groupId>com.github.lookfirst</groupId>
            <artifactId>sardine</artifactId>
            <version>5.10</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-collections4</artifactId>
            <version>4.4</version>
        </dependency>
        <dependency>
            <groupId>org.xmlunit</groupId>
            <artifactId>xmlunit-core</artifactId>
            <version>2.8.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-text</artifactId>
            <version>1.9</version>
        </dependency>
        <dependency>
            <groupId>com.codeborne</groupId>
            <artifactId>selenide</artifactId>
            <version>5.18.0</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>7.3.0</version>
        </dependency>
    </dependencies>
</project>

这是我收到的Jenkins消息:

--- maven-resources-plugin:2.6:testResources (default-testResources) @ MY_PROJECT ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /var/lib/jenkins/workspace/MY_PROJECT/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) - @ MY_PROJECT ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) - @ MY_PROJECT ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.182 s - in TestSuite
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[JENKINS] Recording test results
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  36.339 s
[INFO] Finished at: 2023-05-31T10:53:33Z

在本地,我可以毫无问题地执行测试。你有什么想法,为什么它不从我指定的文件夹中获取测试?先谢谢你

sq1bmfud

sq1bmfud1#

已经修好了。Pom配置不正确,对套件的引用也不正确。谢谢两位的回答

相关问题