知识大全 Junt4 动态代码测试
Posted 知
篇首语:盛年不重来,一日难再晨。及时宜自勉,岁月不待人。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 Junt4 动态代码测试相关的知识,希望对你有一定的参考价值。
Junt4 动态代码测试 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
Junt 动态代码测试 方便与java在线教程编写
Listener java
import java util HashMap;
import junit runner Description;
import junit runner Result;
import junit runner notification Failure;
import junit runner notification RunListener;
public class Listener extends RunListener
public static long begin_mill;
public static long end_mill;
public static long test_begin_mill;
public static long test_end_mill;
public static HashMap<String Boolean> test_map;
@Override
public void testAssumptionFailure(Failure failure)
// TODO Auto generated method stub
super testAssumptionFailure(failure);
@Override
public void testFailure(Failure failure) throws Exception
// TODO Auto generated method stub
super testFailure(failure);
Description description = failure getDescription();
TestDescription text_doc = description getAnnotation(TestDescription class);
String name = description getMethodName();
System out println(this);
test_map put(name false);
// System out println( test + name + ( + text_doc value() + ) + is failure );
@Override
public void testFinished(Description description) throws Exception
// TODO Auto generated method stub
super testFinished(description);
String name = description getMethodName();
TestDescription text_doc = description getAnnotation(TestDescription class);
Boolean value = test_map get(name);
if(value == null)
test_map put(name true);
System out println(this);
// System out println( test + name + ( + text_doc value() + ) + is finished );
@Override
public void testIgnored(Description description) throws Exception
// TODO Auto generated method stub
super testIgnored(description);
@Override
public void testRunFinished(Result result) throws Exception
// TODO Auto generated method stub
super testRunFinished(result);
// System out println( all time + (end_mill begin_mill));
@Override
public void testRunStarted(Description description) throws Exception
// TODO Auto generated method stub
super testRunStarted(description);
begin_mill = System currentTimeMillis();
test_map = new HashMap<String Boolean>();
@Override
public void testStarted(Description description) throws Exception
// TODO Auto generated method stub
super testStarted(description);
String name = description getMethodName();
// System out println( test + name + is started );
TestDescription java
import static java lang annotation ElementType METHOD;
import static java lang annotation RetentionPolicy RUNTIME;
import java lang annotation Retention;
import java lang annotation Target;
@Target(METHOD)
@Retention(RUNTIME)
public @interface TestDescription
String value();
rule:
Practice java
public class Practice
public int sum(int a int b)
return a + b;
PracticeTest java
import junit Assert;
import junit Test;
import junit runner RunWith;
import junit runners JUnit ;
@RunWith(JUnit class)
public class PracticeTest
@Test
@TestDescription( sum( ) > )
public void test ()
Practice a = new Practice();
Assert assertEquals( a sum( ));
@Test
@TestDescription( sum( ) > )
public void test ()
Practice a = new Practice();
Assert assertEquals( a sum( ));
@Test
@TestDescription( sum( ) > )
public void test ()
Practice a = new Practice();
Assert assertEquals( a sum( ));
@Test
@TestDescription( sum( ) > )
public void test ()
Practice a = new Practice();
Assert assertEquals( a sum( ));
Main java
import java util Iterator;
import java util Set;
import junit runner JUnitCore;
import junit runner Result;
public class Main
/**
* @param args
*/
public static void main(String[] args)
// TODO Auto generated method stub
JUnitCore core = new junit runner JUnitCore();
core addListener(new Listener());
Result result = core run(PracticeTest class);
Set<String> set = Listener test_map keySet();
Iterator<String> it = erator();
while(it hasNext())
String name = it next();
boolean is_success = Listener test_map get(name);
String is_success_str = is_success ? success : failure ;
System out println( test + name + : + is_success_str );
cha138/Article/program/Java/ky/201311/28289
相关参考
这篇文章介绍了gridpanel动态加载数据的实例代码有需要的朋友可以参考一下 复制代码代码如下:cha138/Article/program/Java/JSP/201311/20
动态执行C#代码 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 写这篇笔记的理由是因为上篇g提高
知识大全 jquery动态增加text元素以及删除文本内容实例代码
这段代码是通过jquery动态增加限定数额的text(本例为个)以及清除文本内容用到了after()方法追加元素<!以下为script代码开始>复制代码代码如下:<script&
主要功能是动态增减输入框而且支持对各个输入框的检测每个输入框在输入内容后对其进行错误提示 通过字符串拼接将所有的输入框中的内容用“##”这样的格式拼接网页端代码复制代码代码如下:<
JQuery写动态树示例代码 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!本文为大家介绍下使用JQ
用Java测试网络代码 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 网络代码被证明是很难进行完
一个申请单可以包含N个项目添加申请单时就需要动态加入代码了 动态Table表格 <tableborder=width=%id=tabzxname=tabzxalign=centercla
Javascript实现动态菜单添加的实例代码 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!在注册
一个申请单可以包含N个项目添加申请单时就需要动态加入代码了 动态Table表格<tableborder=width=%id=tabzxname=tabzxalign=centerclass
代码如下:<!DOCTYPEPUBLIC"//WC//DTDXHTMLStrict//EN""<xmlns=":lang="en"lang="en"><head&g