Selenium JUnit 5测试结果无法推送至KiwiTCMS报错问题求助
问题解决方案
根因分析
报错
java.lang.ClassNotFoundException: org.junit.jupiter.api.ClassOrderer是JUnit 5版本不兼容导致的问题。ClassOrderer是JUnit 5.8.0版本才新增的API,当前项目的依赖存在版本不一致、依赖不完整的问题,导致类加载失败,测试无法正常执行,更无法推送结果到KiwiTCMS。
解决步骤
- 第一步:在pom.xml中添加JUnit 5 BOM依赖管理,统一所有JUnit 5相关组件的版本,避免版本冲突
- 第二步:替换零散的JUnit依赖,引入完整的junit-jupiter聚合依赖,无需单独引入engine、api等子模块
- 第三步:调整kiwitcms-junit-plugin的依赖scope为test,符合测试插件的使用场景
修改后的完整pom.xml配置
<?xml version="1.0" encoding="UTF-8"?> <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> <groupId>org.example</groupId> <artifactId>test</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> <junit5.version>5.9.2</junit5.version> </properties> <!-- 统一依赖版本管理 --> <dependencyManagement> <dependencies> <!-- JUnit 5 BOM 统一所有JUnit5组件版本 --> <dependency> <groupId>org.junit</groupId> <artifactId>junit-bom</artifactId> <version>${junit5.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <!-- KiwiTCMS JUnit5 插件 --> <dependency> <groupId>org.kiwitcms.java</groupId> <artifactId>kiwitcms-junit-plugin</artifactId> <version>10.0</version> <scope>test</scope> </dependency> <!-- 完整JUnit 5依赖,包含api、engine等所有核心模块 --> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <scope>test</scope> </dependency> </dependencies> </project>
额外配置注意事项
- 测试执行前需要配置KiwiTCMS的连接参数,可通过系统属性或者环境变量配置以下参数:
KIWI_URL:KiwiTCMS服务的访问地址KIWI_USERNAME:KiwiTCMS登录账号KIWI_PASSWORD:KiwiTCMS登录密码
- 当前测试代码不需要修改,修改pom.xml后执行
mvn clean test即可正常运行测试,并自动将结果推送到KiwiTCMS平台。
内容的提问来源于stack exchange,提问作者Zakaria Shahed
相关产品推荐
相关产品推荐

