Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Leq_1
Java_674809
提交
ef7bf9e7
J
Java_674809
项目概览
Leq_1
/
Java_674809
与 Fork 源项目一致
Fork自
inscode / Java
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
Java_674809
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
ef7bf9e7
编写于
3月 24, 2025
作者:
Q
qq_36075618
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Mon Mar 24 21:59:00 CST 2025 inscode
上级
1a987c02
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
69 addition
and
1 deletion
+69
-1
pom.xml
pom.xml
+18
-1
src/test/java/com/example/tests/CalculatorTest.java
src/test/java/com/example/tests/CalculatorTest.java
+27
-0
src/test/java/com/example/tests/TestBase.java
src/test/java/com/example/tests/TestBase.java
+16
-0
src/test/resources/testng.xml
src/test/resources/testng.xml
+8
-0
未找到文件。
pom.xml
浏览文件 @
ef7bf9e7
<project>
<
!-- <
project>
<modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>
<groupId>mygroupid</groupId>
<groupId>mygroupid</groupId>
<artifactId>myartifactid</artifactId>
<artifactId>myartifactid</artifactId>
...
@@ -50,4 +50,21 @@
...
@@ -50,4 +50,21 @@
</plugin>
</plugin>
</plugins>
</plugins>
</build>
</build>
</project> -->
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.example
</groupId>
<artifactId>
testng-demo
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<dependencies>
<dependency>
<groupId>
org.testng
</groupId>
<artifactId>
testng
</artifactId>
<version>
7.8.0
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</project>
</project>
\ No newline at end of file
src/test/java/com/example/tests/CalculatorTest.java
0 → 100644
浏览文件 @
ef7bf9e7
package
com.example.tests
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
public
class
CalculatorTest
extends
TestBase
{
@Test
(
priority
=
1
,
description
=
"验证加法逻辑"
)
public
void
testAddition
()
{
int
result
=
add
(
2
,
3
);
Assert
.
assertEquals
(
result
,
5
,
"加法结果错误"
);
}
@Test
(
priority
=
2
,
dependsOnMethods
=
"testAddition"
)
public
void
testSubtraction
()
{
int
result
=
subtract
(
5
,
2
);
Assert
.
assertEquals
(
result
,
3
,
"减法结果错误"
);
}
// 被测试的方法
private
int
add
(
int
a
,
int
b
)
{
return
a
+
b
;
}
private
int
subtract
(
int
a
,
int
b
)
{
return
a
-
b
;
}
}
\ No newline at end of file
src/test/java/com/example/tests/TestBase.java
0 → 100644
浏览文件 @
ef7bf9e7
package
com
.
example
.
tests
;
import
org
.
testng
.
annotations
.
AfterClass
;
import
org
.
testng
.
annotations
.
BeforeClass
;
public
class
TestBase
{
@
BeforeClass
public
void
setUp
()
{
System
.
out
.
println
(
"全局初始化:例如启动数据库连接或浏览器"
);
}
@
AfterClass
public
void
tearDown
()
{
System
.
out
.
println
(
"全局清理:例如关闭资源"
);
}
}
\ No newline at end of file
src/test/resources/testng.xml
0 → 100644
浏览文件 @
ef7bf9e7
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite
name=
"Default Suite"
>
<test
name=
"Calculator Tests"
verbose=
"2"
>
<classes>
<class
name=
"com.example.tests.CalculatorTest"
/>
</classes>
</test>
</suite>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录