ylbtech-Java-Class-@I:org.junit.Test
1.返回顶部
 
2.返回顶部
 
3.返回顶部
 
4.返回顶部
1、
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&lt;Object&gt;().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;
}
2、
5.返回顶部
 
 
6.返回顶部
 
作者:ylbtech
出处:http://ylbtech.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

Java-Class-@I:org.junit.Test的更多相关文章

  1. Java单元测试工具:JUnit4(一)(二)(三)(四)

    Java单元测试工具:JUnit4(一)--概述及简单例子 Java单元测试工具:JUnit4(二)--JUnit使用详解 Java单元测试工具:JUnit4(三)--JUnit详解之运行流程及常用注 ...

  2. JAVA提高五:注解Annotation

    今天我们学习JDK5.0中一个非常重要的特性,叫做注解.是现在非常流行的一种方式,可以说因为配置XML 比较麻烦或者比容易查找出错误,现在越来越多的框架开始支持注解方式,比如注明的Spring 框架, ...

  3. Java基础14:离开IDE,使用java和javac构建项目

    更多内容请关注微信公众号[Java技术江湖] 这是一位阿里 Java 工程师的技术小站,作者黄小斜,专注 Java 相关技术:SSM.SpringBoot.MySQL.分布式.中间件.集群.Linux ...

  4. Java基础10:全面解读Java异常

    更多内容请关注微信公众号[Java技术江湖] 这是一位阿里 Java 工程师的技术小站,作者黄小斜,专注 Java 相关技术:SSM.SpringBoot.MySQL.分布式.中间件.集群.Linux ...

  5. 软件测试:lab1.Junit and Eclemma

    软件测试:lab1.Junit and Eclemma Task: Install Junit(4.12), Hamcrest(1.3) with Eclipse Install Eclemma wi ...

  6. 浅谈Java代理二:Cglib动态代理-MethodInterceptor

    浅谈Java代理二:Cglib动态代理-MethodInterceptor CGLib动态代理特点: 使用CGLib实现动态代理,完全不受代理类必须实现接口的限制,而且CGLib底层采用ASM字节码生 ...

  7. 浅谈Java代理一:JDK动态代理-Proxy.newProxyInstance

    浅谈Java代理一:JDK动态代理-Proxy.newProxyInstance java.lang.reflect.Proxy:该类用于动态生成代理类,只需传入目标接口.目标接口的类加载器以及Inv ...

  8. java工具包一:日期处理

    作者:NiceCui 本文谢绝转载,如需转载需征得作者本人同意,谢谢. 本文链接:http://www.cnblogs.com/NiceCui/p/7846812.html 邮箱:moyi@moyib ...

  9. 20165329 Java实验二:面向对象编程

    实验内容: 面向对象程序设计-1 实验要求: 提交最后三个JUnit测试用例(正常情况,错误情况,边界情况)都通过的截图 实验步骤: 1.按照老师博客的要求新建一个MyUtil项目 在src内新建ja ...

  10. Java基础教程:注解

    Java基础教程:注解 本篇文章参考的相关资料链接: 维基百科:https://zh.wikipedia.org/wiki/Java%E6%B3%A8%E8%A7%A3 注解基础与高级应用:http: ...

随机推荐

  1. BZOJ 1565: [NOI2009]植物大战僵尸(网络流+缩点)

    传送门 解题思路 最大权闭合子图.但是要注意一些细节,假如有一堆植物形成一个环,那么这些植物都是无敌的,并且他们保护的植物是无敌的,他们保护的保护的植物是无敌 的.所以要缩点,然后拓扑排序一次判无敌, ...

  2. PHP学习(MVC架构与面向对象)

    想好好的学一下php中的一些面向对象的知识,以前只是为了打CTF随意的学了一下,但是为了以后的代码审计(准备PHP这边把thinkphp这个框架好好的学一下). PHP面向对象的基本知识 类与对象 类 ...

  3. web服务nginx和php的相互关系

    nginx和php有什么关系?很多新手可能有这个疑问,我之前学php也没注意这些问题,只管着按文档配置操作,完成php项目就不管了,最近特意总结了一下. php是一门编程语言,讲究说学逗唱...呃,不 ...

  4. C#简单游戏外挂制作(以Warcraft Ⅲ为例)

    网上有很多外挂制作的教程,大多是讲针对大型网络游戏的,主要包含一些抓包.反汇编.C++的知识综合.事实也如此,常见的外挂都是使用VC++写的,从来没有过C#或者其他.NET语言编写的外挂. 作为微软. ...

  5. SQL语句常用优化技巧

    提高SQL语句的执行效率,最常见的方法就是建立索引,以及尽量避免全表扫描. ①.避免在where子句中使用 is null 或 is not null 对字段进行判断. 如:select id fro ...

  6. Openstack组件部署 — Netwotking service组件介绍与网络基本概念

    目录 目录 前文列表 Openstack Networking serivce 基本的Neutron概念 Neutron的抽象对象 网络networks 子网subnets 路由器routers 端口 ...

  7. MarkDown 快速开始 基础教学

    # MarkDown 快速上手 # > [源代码](https://www.cnblogs.com/qiyuexin/p/9932941.html) > by qyx@2018/11/07 ...

  8. 前端(六)—— 伪类选择器:a标签的伪类、内容伪类、索引伪类、取反伪类

    a标签的伪类.内容伪类.索引伪类.取反伪类 一.a标签的四大伪类 :link:未访问状态 :hover:悬浮状态 :active:活跃状态 :visited:已访问状态 四大伪类也可用于其他标签 &l ...

  9. VC++ 2010 创建高级Ribbon界面详解(1)

    运用 VC++ 2010 创建高级 Ribbon 界面详解,包括 Ribbon 界面的结构层次.Ribbon 控件的使用等,ribbon 用户界面,ribbon interface ,ribbon 高 ...

  10. JUC源码分析-线程池篇(三)Timer

    JUC源码分析-线程池篇(三)Timer Timer 是 java.util 包提供的一个定时任务调度器,在主线程之外起一个单独的线程执行指定的计划任务,可以指定执行一次或者反复执行多次. 1. Ti ...