Java-Class-@I:org.junit.Test
ylbtech-Java-Class-@I:org.junit.Test |
1.返回顶部 |
2.返回顶部 |
3.返回顶部 |
4.返回顶部 |
package org.junit; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; /**
* The <code>Test</code> annotation tells JUnit that the <code>public void</code> method
* to which it is attached can be run as a test case. To run the method,
* JUnit first constructs a fresh instance of the class then invokes the
* annotated method. Any exceptions thrown by the test will be reported
* by JUnit as a failure. If no exceptions are thrown, the test is assumed
* to have succeeded.
* <p>
* A simple test looks like this:
* <pre>
* public class Example {
* <b>@Test</b>
* public void method() {
* org.junit.Assert.assertTrue( new ArrayList().isEmpty() );
* }
* }
* </pre>
* <p>
* The <code>Test</code> annotation supports two optional parameters.
* The first, <code>expected</code>, declares that a test method should throw
* an exception. If it doesn't throw an exception or if it throws a different exception
* than the one declared, the test fails. For example, the following test succeeds:
* <pre>
* @Test(<b>expected=IndexOutOfBoundsException.class</b>) public void outOfBounds() {
* new ArrayList<Object>().get(1);
* }
* </pre>
* If the exception's message or one of its properties should be verified, the
* {@link org.junit.rules.ExpectedException ExpectedException} rule can be used. Further
* information about exception testing can be found at the
* <a href="https://github.com/junit-team/junit/wiki/Exception-testing">JUnit Wiki</a>.
* <p>
* The second optional parameter, <code>timeout</code>, causes a test to fail if it takes
* longer than a specified amount of clock time (measured in milliseconds). The following test fails:
* <pre>
* @Test(<b>timeout=100</b>) public void infinity() {
* while(true);
* }
* </pre>
* <b>Warning</b>: while <code>timeout</code> is useful to catch and terminate
* infinite loops, it should <em>not</em> be considered deterministic. The
* following test may or may not fail depending on how the operating system
* schedules threads:
* <pre>
* @Test(<b>timeout=100</b>) public void sleep100() {
* Thread.sleep(100);
* }
* </pre>
* <b>THREAD SAFETY WARNING:</b> Test methods with a timeout parameter are run in a thread other than the
* thread which runs the fixture's @Before and @After methods. This may yield different behavior for
* code that is not thread safe when compared to the same test method without a timeout parameter.
* <b>Consider using the {@link org.junit.rules.Timeout} rule instead</b>, which ensures a test method is run on the
* same thread as the fixture's @Before and @After methods.
*
* @since 4.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface Test { /**
* Default empty exception
*/
static class None extends Throwable {
private static final long serialVersionUID = 1L; private None() {
}
} /**
* Optionally specify <code>expected</code>, a Throwable, to cause a test method to succeed if
* and only if an exception of the specified class is thrown by the method. If the Throwable's
* message or one of its properties should be verified, the
* {@link org.junit.rules.ExpectedException ExpectedException} rule can be used instead.
*/
Class<? extends Throwable> expected() default None.class; /**
* Optionally specify <code>timeout</code> in milliseconds to cause a test method to fail if it
* takes longer than that number of milliseconds.
* <p>
* <b>THREAD SAFETY WARNING:</b> Test methods with a timeout parameter are run in a thread other than the
* thread which runs the fixture's @Before and @After methods. This may yield different behavior for
* code that is not thread safe when compared to the same test method without a timeout parameter.
* <b>Consider using the {@link org.junit.rules.Timeout} rule instead</b>, which ensures a test method is run on the
* same thread as the fixture's @Before and @After methods.
* </p>
*/
long timeout() default 0L;
}
5.返回顶部 |
6.返回顶部 |
![]() |
作者:ylbtech 出处:http://ylbtech.cnblogs.com/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。 |
Java-Class-@I:org.junit.Test的更多相关文章
- Java单元测试工具:JUnit4(一)(二)(三)(四)
Java单元测试工具:JUnit4(一)--概述及简单例子 Java单元测试工具:JUnit4(二)--JUnit使用详解 Java单元测试工具:JUnit4(三)--JUnit详解之运行流程及常用注 ...
- JAVA提高五:注解Annotation
今天我们学习JDK5.0中一个非常重要的特性,叫做注解.是现在非常流行的一种方式,可以说因为配置XML 比较麻烦或者比容易查找出错误,现在越来越多的框架开始支持注解方式,比如注明的Spring 框架, ...
- Java基础14:离开IDE,使用java和javac构建项目
更多内容请关注微信公众号[Java技术江湖] 这是一位阿里 Java 工程师的技术小站,作者黄小斜,专注 Java 相关技术:SSM.SpringBoot.MySQL.分布式.中间件.集群.Linux ...
- Java基础10:全面解读Java异常
更多内容请关注微信公众号[Java技术江湖] 这是一位阿里 Java 工程师的技术小站,作者黄小斜,专注 Java 相关技术:SSM.SpringBoot.MySQL.分布式.中间件.集群.Linux ...
- 软件测试:lab1.Junit and Eclemma
软件测试:lab1.Junit and Eclemma Task: Install Junit(4.12), Hamcrest(1.3) with Eclipse Install Eclemma wi ...
- 浅谈Java代理二:Cglib动态代理-MethodInterceptor
浅谈Java代理二:Cglib动态代理-MethodInterceptor CGLib动态代理特点: 使用CGLib实现动态代理,完全不受代理类必须实现接口的限制,而且CGLib底层采用ASM字节码生 ...
- 浅谈Java代理一:JDK动态代理-Proxy.newProxyInstance
浅谈Java代理一:JDK动态代理-Proxy.newProxyInstance java.lang.reflect.Proxy:该类用于动态生成代理类,只需传入目标接口.目标接口的类加载器以及Inv ...
- java工具包一:日期处理
作者:NiceCui 本文谢绝转载,如需转载需征得作者本人同意,谢谢. 本文链接:http://www.cnblogs.com/NiceCui/p/7846812.html 邮箱:moyi@moyib ...
- 20165329 Java实验二:面向对象编程
实验内容: 面向对象程序设计-1 实验要求: 提交最后三个JUnit测试用例(正常情况,错误情况,边界情况)都通过的截图 实验步骤: 1.按照老师博客的要求新建一个MyUtil项目 在src内新建ja ...
- Java基础教程:注解
Java基础教程:注解 本篇文章参考的相关资料链接: 维基百科:https://zh.wikipedia.org/wiki/Java%E6%B3%A8%E8%A7%A3 注解基础与高级应用:http: ...
随机推荐
- 泛型(Java 5 开始)
前言 Java 5 开始之前,从集合读取的数据都必须进行类型转换,如果插入错误的数据就会报错. 有了泛型,编译器会自动为你的插入进行转换,并在插入时告知是否插入了类型错误的对象. 将类型由原来的具体的 ...
- 存储emoji表情,修改字符集为utf8mb4
SHOW VARIABLES WHERE Variable_name LIKE 'character_set_%' OR Variable_name LIKE 'collation%'; SET ch ...
- 【SQL】Mysql常用sql语句记录
1.创建用户.赋予权限 CREATE DATABASE scadm DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE USER 's ...
- PHP FILTER_VALIDATE_INT 过滤器
定义和用法 FILTER_VALIDATE_INT 过滤器把值作为整数来验证. Name: "int" ID-number: 257 可能的选项或标志: min_range - 规 ...
- 计算1到N中包含数字1的个数
转自:http://pandonix.iteye.com/blog/204840 Mark N为正整数,计算从1到N的所有整数中包含数字1的个数.比如,N=10,从1,2...10,包含有2个数字1. ...
- Tomcat运行错误示例
tomcat运行错误示例 当出现这种错误时,如果是自己配置的tomcat,需要找/conf/server.xml文件. 如果是使用的eclipse tomcat 插件,需要在你的工作空间 找到 如下文 ...
- PHP面试 PHP基础知识 四(流程控制)
流程控制 PHP遍历数组的三种方式及各自的区别 三种方式:使用for循环.使用foreach循环.使用while.list().each()组合循环 区别:foe循环只能遍历索引数组,foeach可以 ...
- Codeforces 743C - Vladik and fractions (构造)
Codeforces Round #384 (Div. 2) 题目链接:Vladik and fractions Vladik and Chloe decided to determine who o ...
- pytest_fixture--scope="session"
import pytest@pytest.fixture(scope="session")def login(): print("\n输入用户名密码登陆! configt ...
- 换盘符cd的用法
如果是在本盘内切换文件夹,直接使用cd 后面跟地址即可. 如果是跨区切换地址,cd 后面就需要跟/d,斜杠d, /d就代表着跨分区切换地址. cd /d d:\ C:\ProgramData\Anac ...