use of org.junit.runner.Request in project junit4 by junit-team.
the class MaxStarterTest method preferFast.
@Test
public void preferFast() {
Request request = Request.aClass(TwoUnEqualTests.class);
fMax.run(request);
Description thing = fMax.sortedLeavesForTest(request).get(1);
assertEquals(Description.createTestDescription(TwoUnEqualTests.class, "slow"), thing);
}
use of org.junit.runner.Request in project junit4 by junit-team.
the class MaxStarterTest method preferRecentlyFailed.
@Test
public void preferRecentlyFailed() {
Request request = Request.aClass(TwoTests.class);
fMax.run(request);
List<Description> tests = fMax.sortedLeavesForTest(request);
Description dontSucceed = Description.createTestDescription(TwoTests.class, "dontSucceed");
assertEquals(dontSucceed, tests.get(0));
}
use of org.junit.runner.Request in project junit4 by junit-team.
the class MaxStarterTest method correctErrorFromHalfMalformedTest.
@Test
public void correctErrorFromHalfMalformedTest() {
Request request = Request.aClass(HalfMalformedJUnit38TestMethod.class);
JUnitCore core = new JUnitCore();
Request sorted = fMax.sortRequest(request);
Runner runner = sorted.getRunner();
Result result = core.run(runner);
Failure failure = result.getFailures().get(0);
assertThat(failure.toString(), containsString("MalformedJUnit38TestMethod"));
assertThat(failure.toString(), containsString("testNothing"));
assertThat(failure.toString(), containsString("isn't public"));
}
use of org.junit.runner.Request in project junit4 by junit-team.
the class MaxStarterTest method sortTestsInMultipleClasses.
@Test
public void sortTestsInMultipleClasses() {
Request request = Request.classes(Computer.serial(), TwoTests.class, TwoTests.class);
fMax.run(request);
List<Description> tests = fMax.sortedLeavesForTest(request);
Description dontSucceed = Description.createTestDescription(TwoTests.class, "dontSucceed");
assertEquals(dontSucceed, tests.get(0));
assertEquals(dontSucceed, tests.get(1));
}
use of org.junit.runner.Request in project nutz by nutzam.
the class AdvancedTestAll method main.
public static void main(String[] args) {
//得到所有带@Test的方法
List<Class<?>> list = Scans.me().scanPackage("org.nutz");
List<Request> reqs = new ArrayList<Request>();
Map<Request, Method> reqMap = new HashMap<Request, Method>();
for (Class<?> clazz : list) {
Method[] methods = clazz.getMethods();
for (Method method : methods) {
if (method.getAnnotation(Test.class) != null) {
Request req = Request.method(clazz, method.getName());
reqs.add(req);
reqMap.put(req, method);
}
}
}
System.out.printf("Found %d Test Class\n", reqs.size());
//先按普通顺序跑一次
TestResult simpleTestResult = test(reqs, "normal", reqMap);
//倒序跑一次
Collections.reverse(reqs);
TestResult reverseTestResult = test(reqs, "reverse", reqMap);
//乱序跑3次
Collections.shuffle(reqs);
TestResult shuffleTestResult_A = test(reqs, "shuffle_A", reqMap);
Collections.shuffle(reqs);
TestResult shuffleTestResult_B = test(reqs, "shuffle_B", reqMap);
Collections.shuffle(reqs);
TestResult shuffleTestResult_C = test(reqs, "shuffle_C", reqMap);
System.out.println("正常顺序------------------------------------------------");
printResult(simpleTestResult);
System.out.println("反序------------------------------------------------");
printResult(reverseTestResult);
System.out.println("乱序A------------------------------------------------");
printResult(shuffleTestResult_A);
System.out.println("乱序B------------------------------------------------");
printResult(shuffleTestResult_B);
System.out.println("乱序C------------------------------------------------");
printResult(shuffleTestResult_C);
System.out.println("-------------------------------------------------------Done");
}
Aggregations