-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpom.xml
More file actions
136 lines (125 loc) · 6.21 KB
/
Copy pathpom.xml
File metadata and controls
136 lines (125 loc) · 6.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?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.apache.tsfile</groupId>
<artifactId>java-tsfile-api-test</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- tsfile依赖 -->
<dependency>
<groupId>org.apache.tsfile</groupId>
<artifactId>tsfile</artifactId>
<version>2.3.2-SNAPSHOT</version>
</dependency>
<!-- testng依赖 -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.7.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- 测试执行插件:显式声明以配置 argLine,开启断言并兼容 jacoco -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<!--
@{argLine} 接住 jacoco prepare-agent 注入的 agent 参数(jacoco 0.8.8 默认写入名为 argLine 的属性),
再追加 -ea 开启断言。必须用 @{argLine}(Maven late replacement)而非 ${argLine}:
直接写死 <argLine>-ea</argLine> 会覆盖 jacoco agent 导致覆盖率归零;
@{} 在属性缺失(无 jacoco 时)会安全替换为空,不会报错。
-Dtsfile.locale=en:锁定 tsfile 的 i18n 错误消息为英文,不受运行环境 locale(如 zh_CN)影响,
使异常 message 断言稳定。tsfile 的 Messages 类在类加载时解析一次 locale,system property
优先级最高,故必须经此传入(测试代码里 Locale.setDefault 有加载时序风险,不可靠)。
-->
<argLine>@{argLine} -ea -Dtsfile.locale=en</argLine>
</configuration>
</plugin>
<!-- 可以生成一个HTML格式的测试报告,显示测试结果的详细信息 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- Maven 编译插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
</plugin>
<!-- Build Helper 插件,用于向 Maven 项目添加额外的源码目录 -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<!-- 这里我们将 code/src 目录添加为额外的源码目录,使其中的代码也能被编译和处理 -->
<sources>
<source>code/src</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<!-- JaCoCo 代码覆盖率插件,用于生成代码覆盖率报告 -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<configuration>
<!-- 指定 jacoco.exec 数据文件的位置 -->
<dataFile>target/jacoco.exec</dataFile>
<!-- 指定生成报告的输出目录 -->
<outputDirectory>target/jacoco-report</outputDirectory>
</configuration>
<executions>
<!-- prepare-agent 目标会在测试阶段初始化 JaCoCo agent -->
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- report 目标会在测试完成后生成覆盖率报告 -->
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- 指定数据文件位置 -->
<dataFile>target/jacoco.exec</dataFile>
<!-- 指定报告输出目录 -->
<outputDirectory>target/jacoco-report</outputDirectory>
<!-- 指定要包含在报告中的类,这里只包含 org/apache/tsfile 包下的所有类 -->
<includes>
<include>org/apache/tsfile/**/*</include>
</includes>
<!-- 排除 src/main/java 目录编译出的类文件 -->
<excludes>
<exclude>examples/**</exclude>
<exclude>utils/**</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>