JUnit实战(2) - JUnit核心(使用Suite来组合测试)
创建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>
JUnit实战(2) - JUnit核心(使用Suite来组合测试)的更多相关文章
- JUnit实战(1) - JUnit起步(Parameterized参数化测试)
创建Java Project项目,项目名称:ch01-jumpstart Calculator.java public class Calculator { public double add(dou ...
- 用junit Test Suite来组合测试
在测试过程中,有时可能想一次性运行所有的测试类,或是选择性的运行某些测试类.这样的话我们就可以用TestSuite来统一管理我们的测试类. 比如说我现在有三个测试类:junitTest4,TestCa ...
- 【读书笔记】Junit实战
Junit实战读书笔记 第一章节 探索Junit: Junit是1997年Erich Gammay和Kent Beck一同创建的一个简单有效的测试框架,其中Erich Gammay是经典<设计模 ...
- 《Junit实战》读书笔记
核心原则:任何没有经过自动测试的程序功能都可以当做不存在 单元测试框架的大三规则: 1.每个单元测试都必须独立于其他所有单元测试而运行 2.框架应该以单个测试为单元来检测和报告错误 3.应该易于定义要 ...
- 《JUnit实战(第2版)》读书笔记
第1章 JUnit起步 主要了解JUnit,如何安装.运行JUnit 要点 JUnit4不需要像JUnit3那样extends TestCase类 Junit4基本都是用注解(该书都翻译为注释,但我喜 ...
- junit源码解析--核心类
JUnit 的概念及用途 JUnit 是由 Erich Gamma 和 Kent Beck 编写的一个开源的单元测试框架.它属于白盒测试,只要将待测类继承 TestCase 类,就可以利用 JUnit ...
- JUnit 3.8 让所有测试程序 实现 复合的测试(TestSuite)
之前是单个单个程序测试,这种方式在测试类比较少的时候可行, 但测试类多了,单个单个的这个测试方式就不推荐了,那得使用 复合的测试了 一个TestSuite是一个复合的测试.它运行测试用例集. 这个 ...
- The <classpath> or <modulepath> for <junit> must include junit.jar if not in Ant's own classpath
The <classpath> or <modulepath> for <junit> must include junit.jar if not in Ant's ...
- Java多线程编程实战指南(核心篇)读书笔记(五)
(尊重劳动成果,转载请注明出处:http://blog.csdn.net/qq_25827845/article/details/76730459冷血之心的博客) 博主准备恶补一番Java高并发编程相 ...
随机推荐
- python学习之list
list: 创建:list = [5,7,9] 取值和改值:list[1] = list[1] * 5 列表尾插入:list.append(4) 去掉第0个值并返回第0个值的数值:list.pop(0 ...
- uptime
linux uptime命令主要用于获取主机运行时间和查询linux系统负载等信息.uptime命令过去只显示系统运行多久.现在,可以显示系统已经运行了多长时间,信息显示依次为:现在时间.系统已经运行 ...
- 查看文章strncpy()功能更好的文章
strncpy()功能 原型:extern char *strncpy(char *dest, char *src, int n); 使用方法:#include <string.h> ...
- Android:What is ART?
背景:Android4.2之前,安卓手机系统的应用程序均在Dalvik Java的虚拟机上执行,这样的执行模式还要依靠一个编译器来实现与应用程序的沟通.应用程序每次执行时,都须要将程序内的代码转变为机 ...
- C,C++中的static
在C和C++中,static都有两种基本的含义,并且这两种含义经常是互相有冲突的: 1) 在固定的地址上分配,也就是说对象是在一个特殊的静态数据区上创建的,而不是每次 函数调用时在堆栈上产生的.这也是 ...
- Net 高效开发
Net 高效开发之不可错过的实用工具 工欲善其事,必先利其器,没有好的工具,怎么能高效的开发出高质量的代码呢?本文为各ASP.NET 开发者介绍一些高效实用的工具,涉及SQL 管理,VS插件,内存 ...
- 【leetCode百题成就】Gas Station解题报告
题目: There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. ...
- Facebook Hacker Cup 2015 Round 1--Corporate Gifting(树动态规划)
原标题:https://www.facebook.com/hackercup/problems.php?pid=759650454070547&round=344496159068801 题意 ...
- 联想昭阳e43l笔记本配置
驱动精灵硬件检测报告 版本:2015.3.26.1363(8.1.326.1363)========================================================== ...
- 【Android进阶】Activity的四种加载模式
Activity的四种加载模式: 1.standard :系统的默认模式,一次跳转即会生成一个新的实例.假设有一个activity命名为Act1, 执行语句:startActivity(new Int ...