2022.5.11新增
前2篇见
基于Spring Boot + HttpClient框架的多平台多接口数据一致性校验diff测试1
基于Spring Boot + HttpClient框架的多平台多接口数据一致性校验diff测试2
maven仓库地址
https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-failsafe-plugin/3.0.0-M6
5. super-jacoco
滴滴开源Super-jacoco:java代码覆盖率收集平台文档
4. jacoco
Jacoco--测试覆盖率工具
IDEA插件IDEA自带Jacoco单元测试分析工具, *** 作步骤如下
4-1.选择编辑配置 “Edit Configurations”
4-2.添加单元测试类型,选择被测文件,此处以TestNG为例,测试所有代码(不包含lib)
4-3.选择工具jacoco
4-4.以覆盖率模式运行测试用例,点击第3个图标
4-5.运行完成后自动生成测试报告
MAVEN在pom.xml文件中添加以下插件后,运行 mvn test 即可在target/site/jacoco文件夹下生成报告。
如果想要跳过失败的测试用例,请使用 mvn test -Dmaven.test.failure.ignore=true
org.jacoco jacoco-maven-plugin 0.8.2-SNAPSHOT default-prepare-agent prepare-agent default-report test report default-check check 复制代码
运行时测试
jacoco支持程序运行中监控执行情况。下面介绍直接运行和tomcat服务器运行两种监控方式
3. 如遇
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project cloud-api: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
解决办法:mac Big Sur系统 mvn打包报错:No compiler is provided in this environment. Perhaps you are running on a JRE-阿里云开发者社区
macos的jdk下载地址 jdk-8u333-mac.dmg
Java Downloads | Oracle
➜ Home vim ~/.bash_profile 编辑配置文件
➜ Home java -version 查看java版本
java version "1.8.0_333"
Java(TM) SE Runtime Environment (build 1.8.0_333-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.333-b02, mixed mode)
➜ Home mvn -version 查看mvn版本
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T02:33:14+08:00)
Maven home: /usr/local/Cellar/maven/3.5.4/libexec
Java version: 1.8.0_333, vendor: Oracle Corporation, runtime: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "11.2.1", arch: "x86_64", family: "mac"
如上发现
Java version 正确,但是 runtime 值为 /Library/Internet Plug-Ins/JavaAppletPlugin.plugin
进入 /Library/Internet Plug-Ins/ 目录,删除 /Library/Internet Plug-Ins/JavaAppletPlugin.plugin
重新执行 mvn -version
runtime 正确,如下图所示(装了JDK9,JDK8也类似)。
cd /Library/Internet\ Plug-Ins
sudo rm -rf JavaAppletPlugin.plugin
mvn -version runtime
在本地重新执行➜ cloud git:(master) ✗ mvn clean test
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? 报错没有了
如遇
错误:找不到或无法加载主类
cd /Library/Java/JavaVirtualMachines
sudo rm -rf jdk1.8.0_281.jdk
File - Project Structure - Project 编辑SDK
把/Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home
改为
由于JDK版本升级了,所以这里也需要修改
qa@lishandeMacBook-Pro-10:~$java -version
java version "1.8.0_333"
Java(TM) SE Runtime Environment (build 1.8.0_333-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.333-b02, mixed mode)
qa@lishandeMacBook-Pro-10:~$mvn -version
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T02:33:14+08:00)
Maven home: /usr/local/Cellar/maven/3.5.4/libexec
Java version: 1.8.0_333, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_333.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "11.2.1", arch: "x86_64", family: "mac"
如果还是不行 菜单-Build-Rebuild Project
2. jacoco配置
Java单元覆盖率工具JaCoCo详细理解和使用(配置+示例)
1. Intellij IDEA出现错误error:java:⽆效的源发⾏版:11解决⽅法
Preference-Compiler-Java Compiler
module设置为8
pom文件的source target设置为8
org.apache.maven.plugins
maven-compiler-plugin
8
UTF8
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)