/** * Run all the tests in <code>class</code>. * * @return a {@link Result} describing the details of the test run and the failed tests. */ public Result run(Class<?> testClass) { return run(Request.aClass(testClass)); }
/** * The result of running JUnit on {@code type} */ public static PrintableResult testResult(Class<?> type) { return testResult(Request.aClass(type)); }
/** * Run all the tests in <code>class</code>. * * @return a {@link Result} describing the details of the test run and the failed tests. */ public Result run(Class<?> testClass) { return run(Request.aClass(testClass)); }
/** * The result of running JUnit on {@code type} */ public static PrintableResult testResult(Class<?> type) { return testResult(Request.aClass(type)); }
/** * Create a <code>Request</code> that, when processed, will run a single test. * This is done by filtering out all other tests. This method is used to support rerunning * single tests. * * @param clazz the class of the test * @param methodName the name of the test * @return a <code>Request</code> that will cause a single test be run */ public static Request method(Class<?> clazz, String methodName) { Description method = Description.createTestDescription(clazz, methodName); return Request.aClass(clazz).filterWith(method); }
/** * Create a <code>Request</code> that, when processed, will run a single test. * This is done by filtering out all other tests. This method is used to support rerunning * single tests. * * @param clazz the class of the test * @param methodName the name of the test * @return a <code>Request</code> that will cause a single test be run */ public static Request method(Class<?> clazz, String methodName) { Description method = Description.createTestDescription(clazz, methodName); return Request.aClass(clazz).filterWith(method); }
public static Failure runTestWithExpectedFailure(final Class<?> test) { JUnitCore junitCore = new JUnitCore(); Result result = junitCore.run(Request.aClass(test).getRunner()); List<Failure> failures = result.getFailures(); assertThat(failures).hasSize(1); return failures.get(0); }
public static Result runTestWithValidation(final Class<?> test) { JUnitCore junitCore = new JUnitCore(); Result result = junitCore.run(Request.aClass(test).getRunner()); List<Failure> failures = result.getFailures(); if (!failures.isEmpty()) { Failure firstFailure = failures.get(0); throw new AssertionError(firstFailure.getException()); } assertThat(result.wasSuccessful()).isTrue(); return result; }
public static Result runTest(final Class<?> test) { JUnitCore junitCore = new JUnitCore(); return junitCore.run(Request.aClass(test).getRunner()); }
private Runner buildRunner(Description each) { if (each.toString().equals("TestSuite with 0 tests")) { return Suite.emptySuite(); } if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) { // This is cheating, because it runs the whole class // to get the warning for this method, but we can't do better, // because JUnit 3.8's // thrown away which method the warning is for. return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each))); } Class<?> type = each.getTestClass(); if (type == null) { throw new RuntimeException("Can't build a runner from description [" + each + "]"); } String methodName = each.getMethodName(); if (methodName == null) { return Request.aClass(type).getRunner(); } return Request.method(type, methodName).getRunner(); }
public static List<Failure> runTestWithExpectedFailures(final Class<?> test) { JUnitCore junitCore = new JUnitCore(); Result result = junitCore.run(Request.aClass(test).getRunner()); List<Failure> failures = result.getFailures(); assertThat(failures).isNotEmpty(); return failures; } }
private Runner buildRunner(Description each) { if (each.toString().equals("TestSuite with 0 tests")) { return Suite.emptySuite(); } if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) { // This is cheating, because it runs the whole class // to get the warning for this method, but we can't do better, // because JUnit 3.8's // thrown away which method the warning is for. return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each))); } Class<?> type = each.getTestClass(); if (type == null) { throw new RuntimeException("Can't build a runner from description [" + each + "]"); } String methodName = each.getMethodName(); if (methodName == null) { return Request.aClass(type).getRunner(); } return Request.method(type, methodName).getRunner(); }
JUnitCore core = new JUnitCore(); core.addListener(new RL()); Request r = Request.aClass(testCase); return core.run(r.filterWith(new Filter() {
JUnitCore core = new JUnitCore(); core.addListener(new RL()); Request r = Request.aClass(testCase); return core.run( r.filterWith(
@Test public void testWorkingCategoryAndParameterized() { Request request = Request.aClass(WorkingCategoryClass.class); ExposedParameterized runner = (ExposedParameterized) request.getRunner(); request = request.filterWith(new CategoryFilter((ExposedGetAnnotations) runner.getChildren().get(0))); Result result = new JUnitCore().run(request); assertEquals(2, result.getRunCount()); }
@Test public void testBrokenCategoryAndParameterized() { Request request = Request.aClass(BrokenCategoryClass.class); ExposedParameterized runner = (ExposedParameterized) request.getRunner(); request = request.filterWith(new CategoryFilter( (ExposedBlockJUnit4ClassRunnerWithParameters) runner.getChildren().get(0))); Result result = new JUnitCore().run(request); assertEquals( "Yeah!! This might actually mean we've upgraded to JUnit 4.13. Hurry up already and delete this hack.", 1, result.getRunCount()); }
/** * The result of running JUnit on {@code type} */ public static PrintableResult testResult(Class<?> type) { return testResult(Request.aClass(type)); }
/** * Run all the tests in <code>class</code>. * * @return a {@link Result} describing the details of the test run and the failed tests. */ public Result run(Class<?> testClass) { return run(Request.aClass(testClass)); }
/** * Create a <code>Request</code> that, when processed, will run a single test. * This is done by filtering out all other tests. This method is used to support rerunning * single tests. * * @param clazz the class of the test * @param methodName the name of the test * @return a <code>Request</code> that will cause a single test be run */ public static Request method(Class<?> clazz, String methodName) { Description method = Description.createTestDescription(clazz, methodName); return Request.aClass(clazz).filterWith(method); }
private Runner buildRunner(Description each) { if (each.toString().equals("TestSuite with 0 tests")) { return Suite.emptySuite(); } if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) { // This is cheating, because it runs the whole class // to get the warning for this method, but we can't do better, // because JUnit 3.8's // thrown away which method the warning is for. return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each))); } Class<?> type = each.getTestClass(); if (type == null) { throw new RuntimeException("Can't build a runner from description [" + each + "]"); } String methodName = each.getMethodName(); if (methodName == null) { return Request.aClass(type).getRunner(); } return Request.method(type, methodName).getRunner(); }