繁体   English   中英

在 jenkins 构建上运行我的 junit 测试时遇到错误

[英]Running into errors while running my junit tests on jenkins build

当前的工作流程如下:在构建的 docker 图像可以部署到任何地方(通过詹金斯)之前,我的 java 服务(球衣)必须通过一个质量门。 此质量门包括最小测试覆盖率。 我的测试能够在本地 IDE(Intellij Idea)上运行并通过,但是在 jenkins 中构建时,在运行测试时出现以下错误:

test1: javax.el.ELUtil.getExpressionFactory()Ljavax/el/ExpressionFactory;
test2: Could not initialize class "classBeingTested"

我在测试文件夹中添加了一个配置文件 (run.poperties)、一个日志配置文件 (log42j),我知道它们按预期运行,因为并非我的所有测试都因这些错误而失败。 对于第一个错误,我在我的 pom 文件中添加了以下额外的依赖项(基于这个 SO 问题):

<dependency>
     <groupId>org.glassfish.web</groupId>
     <artifactId>javax.el</artifactId>
     <version>2.2.4</version>
</dependency>
<dependency>
     <groupId>javax.el</groupId>
     <artifactId>javax.el-api</artifactId>
     <version>2.2.5</version>
 </dependency>

但是不好。 仍然面临错误。 关于无法初始化 class 的第二个错误,我完全不知道为什么会出现这种情况,但我也明白这可能非常适合我的项目结构。 对任何一个错误的任何帮助都会非常有帮助。 即使是在我的本地重新创建它的合理方法也会非常有帮助,因为现在,我不知道这些错误是从哪里来的。

PS:我主要是 python 开发人员,所以 java 不是我的强项。 如果我的问题不包含正确的信息,我提前道歉。 请让我知道,如果需要,我会添加其他相关详细信息

这是由与 javax 依赖性的一些潜在冲突引起的。 在这里发布我的最终依赖列表:

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
</dependency>

<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter</artifactId>
    <version>5.5.2</version>
    <scope>test</scope>
</dependency>


<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-core</artifactId>
    <version>3.7.0</version>
</dependency>
<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-inline</artifactId>
    <version>3.7.0</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>org.junit.platform</groupId>
    <artifactId>junit-platform-engine</artifactId>
    <version>1.5.2</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.junit.vintage</groupId>
    <artifactId>junit-vintage-engine</artifactId>
    <version>5.4.0</version>
    <scope>test</scope>
</dependency>


<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-engine</artifactId>
    <version>5.4.0</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-junit-jupiter</artifactId>
    <version>3.1.0</version>
    <scope>test</scope>
</dependency>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM