踩坑系统之基于 maven 的 SSM 项目 junit 多次执行

1. 问题展示(困扰了好多天,吐了)

test的目录结构
在这里插入图片描述

  • 只执行一次 run test,但是会执行两次 findAllAreaTest 方法。
  • 通过 debug 在mapper.findxxx 打断点,发现未进入断点就已经执行了一次该方法(info.log中看到日志了)
  • 最终定位到问题:可能是会执行 maven 的 test ,然后在执行一次进入断点?(只是猜测)

2. 解决方案

在这里插入图片描述

  • 在这里跳过测试,效果如下
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building o2o Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ o2o ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 9 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ o2o ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 28 source files to G:\javaInterviewProject\o2o\target\classes
[INFO] 
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ o2o ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ o2o ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to G:\javaInterviewProject\o2o\target\test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ o2o ---
[INFO] Tests are skipped.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.957 s
[INFO] Finished at: 2020-06-30T20:10:14+08:00
[INFO] Final Memory: 19M/212M
[INFO] ------------------------------------------------------------------------

3. 参考文献

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值