Junt
Listener
import java
import org
import org
import org
import org
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
@Override
public void testAssumptionFailure(Failure failure) {
// TODO Auto
super
}
@Override
public void testFailure(Failure failure) throws Exception {
// TODO Auto
super
Description description = failure
TestDescription text_doc = description
String name = description
System
test_map
// System
}
@Override
public void testFinished(Description description) throws Exception {
// TODO Auto
super
String name = description
TestDescription text_doc = description
Boolean value = test_map
if(value == null){
test_map
}
System
// System
}
@Override
public void testIgnored(Description description) throws Exception {
// TODO Auto
super
}
@Override
public void testRunFinished(Result result) throws Exception {
// TODO Auto
super
// System
}
@Override
public void testRunStarted(Description description) throws Exception {
// TODO Auto
super
begin_mill = System
test_map = new HashMap<String
}
@Override
public void testStarted(Description description) throws Exception {
// TODO Auto
super
String name = description
// System
}
}
TestDescription
import static java
import static java
import java
import java
@Target({METHOD})
@Retention(RUNTIME)
public @interface TestDescription {
String value();
}
rule:
Practice
public class Practice {
public int sum(int a
return a + b;
}
}
PracticeTest
import org
import org
import org
import org
@RunWith(JUnit
public class PracticeTest {
@Test
@TestDescription(
public void test
Practice a = new Practice();
Assert
}
@Test
@TestDescription(
public void test
Practice a = new Practice();
Assert
}
@Test
@TestDescription(
public void test
Practice a = new Practice();
Assert
}
@Test
@TestDescription(
public void test
Practice a = new Practice();
Assert
}
}
Main
import java
import java
import org
import org
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto
JUnitCore core = new org
core
Result result = core
Set<String> set = Listener
Iterator<String> it = erator();
while(it
String name = it
boolean is_success = Listener
String is_success_str = is_success ?
System
}
System
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28289.html