JUnit实战(2) - JUnit核心(使用Suite来组合测试)
2024-10-10 04:46:46
创建Java Project项目:ch02-internals
MasterTestSuite.java
package com.manning.junitbook.ch02.internals; import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses; @RunWith(value = Suite.class)
@SuiteClasses(value = { TestSuiteA.class, TestSuiteB.class })
public class MasterTestSuite { }
TestSuiteA.java
package com.manning.junitbook.ch02.internals; import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses; @RunWith(value = Suite.class)
@SuiteClasses(value = { TestCaseA.class })
public class TestSuiteA { }
TestSuiteB.java
package com.manning.junitbook.ch02.internals; import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses; @RunWith(value = Suite.class)
@SuiteClasses(value = { TestCaseB.class })
public class TestSuiteB { }
TestCaseA.java
package com.manning.junitbook.ch02.internals; import static org.junit.Assert.assertEquals; import org.junit.Test; public class TestCaseA {
@Test
public void testA1() {
assertEquals("Dummy test-case", 1+1, 2);
}
}
TestCaseB.java
package com.manning.junitbook.ch02.internals; import static org.junit.Assert.assertTrue; import org.junit.Test; public class TestCaseB {
@Test
public void testB1() {
assertTrue("Dummy test-case", true);
}
}
注:层级关系Suite-->Suite--TestCase.
pom.xml
<?xml version="1.0"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.manning.junitbook</groupId>
<artifactId>junit-in-action-II</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>
<artifactId>ch02-internals</artifactId> <packaging>jar</packaging> <name>JUnitBook Chapter 2 - JUnit internals</name>
<url>http://maven.apache.org</url>
</project>
最新文章
- ES6 - Note2:解构赋值
- hashlib 和 hmac
- 二分图最大权最小权完美匹配模板KM
- Dubbo初探
- 单点登录CAS使用记(二):部署CAS服务器以及客户端
- Spark操作hbase
- wamp+python+CGI+wingIDE
- 通过 [&#39;1&#39;, &#39;2&#39;, &#39;3&#39;].map(parseInt) 学习 map 和 parseInt 函数
- 权限管理系统之项目框架搭建并集成日志、mybatis和分页
- C++ 编译发现 error C2146: syntax error : missing &#39;;&#39; before identifier &#39;m_ctrlserver&#39;
- Excel坐标自动在AutoCad绘图_4
- UML入门学习
- python--第十六天总结(bootstrap)
- AtCoder 瞎做
- Some Conclusions.
- ActiveMQ 入门Nodejs版
- algorithm.sty not found error in LaTeX 解决方法
- WPF Blend 一个动画结束后另一个动画开始执行(一个一个执行)
- 我的Java之旅——答答租车系统的改进
- 【quickhybrid】如何实现一个Hybrid框架
热门文章
- zabbix 监控特定进程
- 边坡优化主题5——bzoj 1096 [ZJOI2007]仓库建设 解决问题的方法
- 两个实验操作系统-ubuntu在安装配置pintos
- uva11922(强行用rope替代spaly)
- BestCoder Round#8 1003
- Windows Phone开发(28):隔离存储B
- linux free
- HT for Web嵌入QtWebKit的client解决方式
- muduo网络图书馆评测
- 分析java.lang.NullPointerException thrown in RelativeLayout measure()