spring-boot - 在jenkins中构建项目时,为junit测试用例的Assert之类的符号找不到符号
问题描述
我的 Maven Spring Boot 项目中有 Junit 测试用例。在构建项目时,找不到诸如 Before、Assert 之类的 junit 符号。可能是什么问题?
部分日志如下,
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/svn repo/delivery-management-
service/src/test/java/com/poc/delivery/DeliveryControllerNewTest.java:[4,24] cannot find symbol
symbol: class Assert
location: package org.junit
[ERROR] /C:/svn repo/delivery-management-
service/src/test/java/com/poc/delivery/DeliveryControllerNewTest.java:[11,17] cannot find symbol
symbol: class Before
location: package org.junit
解决方案
很可能您没有为Assert
静态Before
方法声明导入
import org.junit.Assert;
...
Assert.assertEquals(...)
和
import org.junit.Before;
您还可以运行mvn install
以确保所有依赖项都在本地下载
推荐阅读
- ruby-on-rails - 通过 Ruby 将 Active Admin 中的 jsoneditor 设为只读?
- reactjs - 带有 react-apexcharts 的点击事件
- regex - 正则表达式匹配我需要的文本之间的文本,最大字符数为 20
- django - 如何使用 Django 生成 Word 文档
- single-page-application - 有一种方法可以避免在 PWA 中的每个请求都下载 Spa Bundle
- python - 在 Python 中跨多个模块的每个对象日志记录
- azure-devops - 是否可以在 YAML 文件中定义分支策略?
- python - 如何在函数外使用函数中的变量
- graphviz - 如何在 Graphviz 中垂直对齐子图簇?
- r - 根据另一列的值平均一列的特定行