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高并发编程相 ...
随机推荐
- Scroll View 控件以Thumbnail的方式显示一个目录的全部图片,相似图片浏览器
MAC : XCode -> Scroll View 控件以Thumbnail的方式显示一个目录的全部图片,类似图片浏览器 STEP1:将两个目录复制到project里面ImageBrowser ...
- Phoenix Framework对于Tree该方法节点设置不同的图标,每个
在包Javax Swing的Tree对象.我们需要设置不同的图标为每个节点.它封装了一个通用的方法: 用法: jTree1.setCellRenderer(new TreeNodeRender(cas ...
- css3仿山猫侧边栏
演示:http://jsfiddle.net/Adce2/ 其主要思想: 1, 先画边栏html. 2, 使用css3分别财产close sidebar-content动图片. 3, 使用css3的k ...
- Java进阶 创建和销毁对象
最近准备写点Javase的东西,希望可以帮助大家写出更好的代码. 1.给不可实例化的类提供私有构造器 比如:每个项目中都有很多工具类,提供了很多static类型的方法供大家使用,谁也不希望看到下面的代 ...
- Error 56: The Cisco Systems, Inc. VPN Service has not been started(Cisco VPN在Vista下出现Error 56的解决办法)
Error 56: The Cisco Systems, Inc. VPN Service has not been started(Cisco VPN在Vista下出现Error 56的解决办法) ...
- [转载]使用python上传图片到 yeelink
#/bin/env python # -*-coding:utf=8 -*- import os,time,subprocess,shlex import urllib2 def upload_yee ...
- 【原创】leetCodeOj --- Copy List with Random Pointer 解题报告
题目地址: https://oj.leetcode.com/problems/copy-list-with-random-pointer/ 题目内容: A linked list is given s ...
- Spring的文件上传
Spring在发现包括multipart的请求后,会使用MultipartResolver的实现bean处理文件上传操作,现有採用Servlet3的 org.springframework.web.m ...
- RH033读书笔记(6)-Lab 7 Standard I/O and Pipes
Lab 7 Standard I/O and Pipes 1. [student@stationX ~]$ cat /proc/cpuinfo /proc/meminfo 2. [student@st ...
- 如何js编译的文件dll对于网页电话
1. 加入一个项目的解决方案:JSControl 2. 在这个项目中加入js文件(JScript1.js) 脚本的内容: function showAlert(){ alert('Today is a ...