Package org.junit.runner.manipulation

Examples of org.junit.runner.manipulation.Filter


    public Result start(final Class testCase, final String... methods) {
        try {
            JUnitCore core = new JUnitCore();
            core.addListener(new RL());
            Request r = Request.aClass(testCase);
            return core.run(r.filterWith(new Filter() {

                @Override
                public boolean shouldRun(Description description) {
                    if (description == null) {
                        return false;
View Full Code Here


   * 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(new Filter() {
      @Override
      public boolean shouldRun(Description description) {
        if (description.isTest())
          return desiredDescription.equals(description);
        for (Description each : description.getChildren())
View Full Code Here

    public void testFilter() throws Exception {
        YalpJUnitRunner runner = mock(YalpJUnitRunner.class);
        runner.jUnit4 = new JUnit4(YalpJUnitRunnerTest.class);
        doCallRealMethod().when(runner).filter((Filter) any());

        runner.filter(new Filter() {

            @Override
            public boolean shouldRun(Description arg0) {
                return arg0.getMethodName().indexOf("testFilter") > -1;
            }
View Full Code Here

    /*
     * Instantiate method filter if any.
     */
    String methodFilterGlob = Strings.emptyToNull(System.getProperty(SysGlobals.SYSPROP_TESTMETHOD()));
    Filter methodFilter = Filter.ALL;
    if (methodFilterGlob != null) {
      methodFilter = new MethodGlobFilter(methodFilterGlob);
    }

    /*
     * Important. Run each class separately so that we get separate
     * {@link RunListener} callbacks for the top extracted description.
     */
    while (classNames.hasNext()) {
      Class<?> clazz = instantiate(classNames.next());
      if (clazz == null)
        continue;

      Request request = Request.aClass(clazz);
      try {
        Runner runner = request.getRunner();
        methodFilter.apply(runner);

        fNotifier.fireTestRunStarted(runner.getDescription());
        runner.run(fNotifier);
        fNotifier.fireTestRunFinished(result);
      } catch (NoTestsRemainException e) {
View Full Code Here

    /*
     * Instantiate method filter if any.
     */
    String methodFilterGlob = Strings.emptyToNull(System.getProperty(SysGlobals.SYSPROP_TESTMETHOD()));
    Filter methodFilter = Filter.ALL;
    if (methodFilterGlob != null) {
      methodFilter = new MethodGlobFilter(methodFilterGlob);
    }

    /*
     * Important. Run each class separately so that we get separate
     * {@link RunListener} callbacks for the top extracted description.
     */
    while (classNames.hasNext()) {
      Class<?> clazz = instantiate(classNames.next());
      if (clazz == null)
        continue;

      Request request = Request.aClass(clazz);
      try {
        Runner runner = request.getRunner();
        methodFilter.apply(runner);

        fNotifier.fireTestRunStarted(runner.getDescription());
        runner.run(fNotifier);
        fNotifier.fireTestRunFinished(result);
      } catch (NoTestsRemainException e) {
View Full Code Here

    /*
     * Instantiate method filter if any.
     */
    String methodFilterGlob = Strings.emptyToNull(System.getProperty(SysGlobals.SYSPROP_TESTMETHOD()));
    Filter methodFilter = Filter.ALL;
    if (methodFilterGlob != null) {
      methodFilter = new MethodGlobFilter(methodFilterGlob);
    }

    /*
     * Important. Run each class separately so that we get separate
     * {@link RunListener} callbacks for the top extracted description.
     */
    while (classNames.hasNext()) {
      Class<?> clazz = instantiate(classNames.next());
      if (clazz == null)
        continue;

      Request request = Request.aClass(clazz);
      try {
        Runner runner = request.getRunner();
        methodFilter.apply(runner);

        fNotifier.fireTestRunStarted(runner.getDescription());
        runner.run(fNotifier);
        fNotifier.fireTestRunFinished(result);
      } catch (NoTestsRemainException e) {
View Full Code Here

  }

  @Test(expected = NoTestsRemainException.class)
  public void filteringAwayEverythingThrowsException() throws NoTestsRemainException {
    Filterable runner = (Filterable) Request.aClass(OneTimeSetup.class).getRunner();
    runner.filter(new Filter() {
      @Override
      public boolean shouldRun(Description description) {
        return false;
      }
View Full Code Here

public class FilterableTest {
  public static class FilteredRunner extends Parameterized {
    public FilteredRunner(Class<?> klass) throws Throwable {
      super(klass);
      filter(new Filter() {

        @Override
        public boolean shouldRun(Description description) {
          return !description.getDisplayName().contains("skip");
        }
View Full Code Here

    /*
     * Instantiate method filter if any.
     */
    String methodFilterGlob = Strings.emptyToNull(System.getProperty(JUnit4.SYSPROP_TESTMETHOD));
    Filter methodFilter = Filter.ALL;
    if (methodFilterGlob != null) {
      methodFilter = new MethodGlobFilter(methodFilterGlob);
    }

    /*
     * Important. Run each class separately so that we get separate
     * {@link RunListener} callbacks for the top extracted description.
     */
    for (Class<?> suite : instantiate(classes)) {
      Request request = Request.aClass(suite);
      try {
        Runner runner= request.getRunner();
        methodFilter.apply(runner);
        core.run(runner);       
      } catch (NoTestsRemainException e) {
        // Don't complain if all methods have been filtered out.
        // I don't understand the reason why this exception has been
        // built in to filters at all.
View Full Code Here

      }
    }

    public LuceneTestCaseRunner(Class<?> clazz) throws InitializationError {
      super(clazz);
      Filter f = new Filter() {

        @Override
        public String describe() { return "filters according to TEST_METHOD"; }

        @Override
        public boolean shouldRun(Description d) {
          return TEST_METHOD == null || d.getMethodName().equals(TEST_METHOD);
        }    
      };
     
      try {
        f.apply(this);
      } catch (NoTestsRemainException e) {
        throw new RuntimeException(e);
      }
    }
View Full Code Here

TOP

Related Classes of org.junit.runner.manipulation.Filter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.