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: ...
随机推荐
- psecurity配置
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...
- v-model 双向数据绑定以及修饰符
<!--v-model 实现双向数据绑定 其中一个值发生改变,另一个值也将实时发生改变--> <div id="app09"> <h1>{{ m ...
- A*启发式搜索基础
A*启发式搜索基础 传统的搜索方式是盲目搜索,即到每一步的时候并没有对每种情况进行有效的区分,这样的结果是浪费了大量的时间,对很多没有必要的数据进行了搜索. 而A*算法则在搜索的过程中会选取认为“最优 ...
- C++ STL(一)介绍及string
STL: C++标准模板库的简称,它是C++的一部份.标准C++库的所有的标识符都是在一个名为std的命名空间中定义的 在使用STL中相关模板时,需要包含相关头文件,然后using namespace ...
- Hdu-4757 Tree(可持久化字典树+lca)
题目链接:点这 我的github地址:点这 Problem Description Zero and One are good friends who always have fun wi ...
- selenium之 文件上传所有方法整理总结
本文转载“灰蓝”的原创博客.http://blog.csdn.net/huilan_same/article/details/52439546 文件上传是所有UI自动化测试都要面对的一个头疼问题,今天 ...
- vbs 之 wscript
https://www.jb51.net/article/20919.htm '''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ...
- 前端(五)—— a、img、list标签
a标签.img标签.list标签 一.a标签 1.常用用法 <a href="https://www.baidu.com">前往百度</a> <a h ...
- MySQL 小调研
一. 概况: MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下产品.MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MySQL ...
- visual studio 2013下搭建 安卓,ios,wp app开发平台
1.安装 visual studio 2013 + Microsoft Visual Studio 2013 Update 4+Microsoft Build Tools 2015 2.安装java ...