/** * Returns a Request that only runs contains tests whose {@link Description} * equals <code>desiredDescription</code> * * @param desiredDescription {@link Description} of those tests that should be run * @return the filtered Request */ public Request filterWith(final Description desiredDescription) { return filterWith(Filter.matchMethodDescription(desiredDescription)); }
/** * Returns a Request that only runs tests whose {@link Description} * matches the given description. * * <p>Returns an empty {@code Request} if {@code desiredDescription} is not a single test and filters all but the single * test if {@code desiredDescription} is a single test.</p> * * @param desiredDescription {@code Description} of those tests that should be run * @return the filtered Request */ public Request filterWith(Description desiredDescription) { return filterWith(Filter.matchMethodDescription(desiredDescription)); }
private Request applyFilterSpecs(Request request) { try { for (String filterSpec : filterSpecs) { Filter filter = FilterFactories.createFilterFromFilterSpec( request, filterSpec); request = request.filterWith(filter); } return request; } catch (FilterNotCreatedException e) { return errorReport(e); } }
/** * 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); }
private RunnerTestDescriptor determineRunnerTestDescriptor(Class<?> testClass, Runner runner, List<RunnerTestDescriptorAwareFilter> filters, UniqueId engineId) { RunnerTestDescriptor runnerTestDescriptor = createCompleteRunnerTestDescriptor(testClass, runner, engineId); if (!filters.isEmpty()) { if (runner instanceof Filterable) { Filter filter = createOrFilter(filters, runnerTestDescriptor); Runner filteredRunner = runnerTestDescriptor.toRequest().filterWith(filter).getRunner(); runnerTestDescriptor = createCompleteRunnerTestDescriptor(testClass, filteredRunner, engineId); } else { Runner runnerToReport = (runner instanceof RunnerDecorator) ? ((RunnerDecorator) runner).getDecoratedRunner() : runner; logger.warn(() -> "Runner " + runnerToReport.getClass().getName() // + " (used on " + testClass.getName() + ") does not support filtering" // + " and will therefore be run completely."); } } return runnerTestDescriptor; }
core.addListener(new RL()); Request r = Request.aClass(testCase); return core.run(r.filterWith(new Filter() {
Request r = Request.aClass(testCase); return core.run( r.filterWith( new Filter() {
@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()); }
/** * Returns a Request that only runs contains tests whose {@link Description} * equals <code>desiredDescription</code> * * @param desiredDescription {@link Description} of those tests that should be run * @return the filtered Request */ public Request filterWith(final Description desiredDescription) { return filterWith(Filter.matchMethodDescription(desiredDescription)); }
/** * 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); }
Request request = ... Categories.CategoryFilter filter = Categories.CategoryFilter.include( testutils.SlowTests.class); request = request.filterWith(filter); Result result = JUnitCore.run(request);
/** * Returns a Request that only runs contains tests whose {@link Description} * equals <code>desiredDescription</code> * * @param desiredDescription {@link Description} of those tests that should be run * @return the filtered Request */ public Request filterWith(final Description desiredDescription) { return filterWith(Filter.matchMethodDescription(desiredDescription)); }
/** * Returns a Request that only runs contains tests whose {@link Description} * equals <code>desiredDescription</code> * * @param desiredDescription {@link Description} of those tests that should be run * @return the filtered Request */ public Request filterWith(final Description desiredDescription) { return filterWith(Filter.matchMethodDescription(desiredDescription)); }
/** * Returns a Request that only runs contains tests whose {@link Description} * equals <code>desiredDescription</code> * * @param desiredDescription {@link Description} of those tests that should be run * @return the filtered Request */ public Request filterWith(final Description desiredDescription) { return filterWith(Filter.matchMethodDescription(desiredDescription)); }
private Request applyFilterSpecs(Request request) { try { for (String filterSpec : filterSpecs) { Filter filter = FilterFactories.createFilterFromFilterSpec( request, filterSpec); request = request.filterWith(filter); } return request; } catch (FilterNotCreatedException e) { return errorReport(e); } }
private JUnit4Runner(Class clazz, String methodName, int startInclusive, int endExclusive) { this.request = Request.classes(clazz).filterWith( createFilter(methodName, startInclusive, endExclusive) ); }
/** * 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 Request junitTestsToRunFrom(Class<?> classUnderTest) { if (isJUnit3TestCaseWithWarnings(classUnderTest)) { return new UninstantiableJUnit3TestRequest(classUnderTest); } Request request = Request.classWithoutSuiteMethod(classUnderTest); Class<?>[] junitCategoriesToExclude = readExcludedGroupsFromConfiguration(); CategoryFilter excludeCategoriesFilter = CategoryFilter.exclude(junitCategoriesToExclude); return request.filterWith(excludeCategoriesFilter); }