Beispiel #1
0
 @Override
 public Description getDescription() {
   Description desc = Description.createSuiteDescription(myClassName);
   if (myTests == null) {
     desc.addChild(createTestDescription(ModuleSymbolicSuite.NO_TESTS));
   } else {
     for (String test : myTests) {
       desc.addChild(createTestDescription(test));
     }
   }
   return desc;
 }
Beispiel #2
0
 @Override
 public Description getDescription() {
   Description description =
       Description.createSuiteDescription(getName(), fTestClass.getAnnotations());
   for (T child : getFilteredChildren()) description.addChild(describeChild(child));
   return description;
 }
Beispiel #3
0
 /* 109:    */
 /* 110:    */ private static Description makeDescription(Test test) /* 111:    */ {
   /* 112: 96 */ if ((test instanceof TestCase))
   /* 113:    */ {
     /* 114: 97 */ TestCase tc = (TestCase) test;
     /* 115: 98 */ return Description.createTestDescription(tc.getClass(), tc.getName());
     /* 116:    */ }
   /* 117: 99 */ if ((test instanceof TestSuite))
   /* 118:    */ {
     /* 119:100 */ TestSuite ts = (TestSuite) test;
     /* 120:101 */ String name = ts.getName() == null ? createSuiteDescription(ts) : ts.getName();
     /* 121:102 */ Description description =
         Description.createSuiteDescription(name, new Annotation[0]);
     /* 122:103 */ int n = ts.testCount();
     /* 123:104 */ for (int i = 0; i < n; i++)
     /* 124:    */ {
       /* 125:105 */ Description made = makeDescription(ts.testAt(i));
       /* 126:106 */ description.addChild(made);
       /* 127:    */ }
     /* 128:108 */ return description;
     /* 129:    */ }
   /* 130:109 */ if ((test instanceof Describable))
   /* 131:    */ {
     /* 132:110 */ Describable adapter = (Describable) test;
     /* 133:111 */ return adapter.getDescription();
     /* 134:    */ }
   /* 135:112 */ if ((test instanceof TestDecorator))
   /* 136:    */ {
     /* 137:113 */ TestDecorator decorator = (TestDecorator) test;
     /* 138:114 */ return makeDescription(decorator.getTest());
     /* 139:    */ }
   /* 140:117 */ return Description.createSuiteDescription(test.getClass());
   /* 141:    */ }
Beispiel #4
0
 private static Description makeDescription(Test test) {
   if (test instanceof TestCase) {
     TestCase tc = (TestCase) test;
     return Description.createTestDescription(tc.getClass(), tc.getName(), getAnnotations(tc));
   } else if (test instanceof TestSuite) {
     TestSuite ts = (TestSuite) test;
     String name = ts.getName() == null ? createSuiteDescription(ts) : ts.getName();
     Description description = Description.createSuiteDescription(name);
     int n = ts.testCount();
     for (int i = 0; i < n; i++) {
       Description made = makeDescription(ts.testAt(i));
       description.addChild(made);
     }
     return description;
   } else if (test instanceof Describable) {
     Describable adapter = (Describable) test;
     return adapter.getDescription();
   } else if (test instanceof TestDecorator) {
     TestDecorator decorator = (TestDecorator) test;
     return makeDescription(decorator.getTest());
   } else {
     // This is the best we can do in this case
     return Description.createSuiteDescription(test.getClass());
   }
 }
Beispiel #5
0
 @Override
 public Description getDescription() {
   Description description = Description.createSuiteDescription(getName(), getRunnerAnnotations());
   for (T child : getFilteredChildren()) {
     description.addChild(describeChild(child));
   }
   return description;
 }
 @Override
 public Description getDescription() {
   Description description =
       createFileDescriptionForError(
           runner.getTestClass().getJavaClass(), runner.getUriProvider(), uri);
   for (Throwable each : causes) description.addChild(describeCause(each));
   return description;
 }
 @Override
 public Description getDescription() {
   Description spec = Description.createSuiteDescription(getName(), classAnnotations());
   List<JUnit4TestMethod> testMethods = m_testMethods;
   for (JUnit4TestMethod method : testMethods) {
     spec.addChild(methodDescription(method));
   }
   return spec;
 }
Beispiel #8
0
 @Override
 public Description getDescription() {
   if (description == null) {
     description = Description.createSuiteDescription(getName(), cucumberExamples.getExamples());
     for (Runner child : getChildren()) {
       description.addChild(describeChild(child));
     }
   }
   return description;
 }
  private void runScenario(RunNotifier notifier, Scenario scenario) {
    Description childDescription =
        Description.createTestDescription(getClass(), scenario.getName());
    descr.addChild(childDescription);
    EachTestNotifier eachNotifier = new EachTestNotifier(notifier, childDescription);
    try {
      eachNotifier.fireTestStarted();

      // If a KieSession is not available, fail fast
      if (ksessions == null || ksessions.values().isEmpty()) {
        eachNotifier.addFailure(
            new NullKieSessionException(
                "Unable to get a Session to run tests. Check the project for build errors."));
      } else {

        KieSession ksession = getKSession(scenario.getKSessions());

        if (ksession == null) {
          String ksessionName = getKSessionName(scenario.getKSessions());
          if (ksessionName == null) {
            eachNotifier.addFailure(
                new NullPointerException(
                    "Test scenario runner could not find the default knowledge session."));
          } else {
            eachNotifier.addFailure(
                new NullPointerException(
                    "Test scenario runner could not find a stateful knowledge session with the name \'"
                        + ksessionName
                        + "\'."));
          }
        } else {
          final ScenarioRunner runner = new ScenarioRunner(ksession, maxRuleFirings);
          runner.run(scenario);
          if (!scenario.wasSuccessful()) {
            StringBuilder builder = new StringBuilder();
            for (String message : scenario.getFailureMessages()) {
              builder.append(message).append("\n");
            }
            eachNotifier.addFailedAssumption(new AssumptionViolatedException(builder.toString()));
          }

          // FLUSSSSSH!
          for (FactHandle factHandle : ksession.getFactHandles()) {
            ksession.delete(factHandle);
          }
        }
      }
    } catch (Throwable t) {
      eachNotifier.addFailure(t);
    } finally {
      // has to always be called as per junit docs
      eachNotifier.fireTestFinished();
    }
  }
  public InternalRemoteRunner(
      Class<?> testClass, String endpoint, Class<? extends Runner> remoteRunnerClass)
      throws InitializationError {
    super(testClass);
    this.testClass = testClass;
    this.remoteRunnerClass = remoteRunnerClass;
    TestClass tc = new TestClass(testClass);

    description = Description.createTestDescription(testClass, tc.getName(), tc.getAnnotations());

    for (FrameworkMethod method : tc.getAnnotatedMethods(Test.class)) {
      String methodName = method.getName();
      Description child =
          Description.createTestDescription(testClass, methodName, method.getAnnotations());

      methodNames.put(child, methodName);
      description.addChild(child);
    }

    if (executorService == null) {
      String ep = System.getProperty("junit.remote.endpoint");
      if (ep == null) {
        ep = endpoint;
      }

      for (String e : ep.split(",")) {
        if (e.trim().equals("")) {
          continue;
        }
        endpoints.add(e.trim());
      }
      executorService = Executors.newFixedThreadPool(endpoints.size());
    }

    setScheduler(
        new RunnerScheduler() {
          @Override
          public void schedule(final Runnable childStatement) {
            SEMAPHORE.reducePermits(1);
            executorService.submit(new SemaphoreDelegate(childStatement));
          }

          @Override
          public void finished() {
            try {
              SEMAPHORE.acquire();
              SEMAPHORE.release();
            } catch (InterruptedException ignore) {
              Thread.currentThread().interrupt();
            }
          }
        });
  }
 Description describeMethod() {
   Object[] params = paramsFromAnnotation();
   Description parametrised = Description.createSuiteDescription(method.name());
   for (int i = 0; i < params.length; i++) {
     /*
     Object paramSet = params[i];
     parametrised.addChild(Description.createTestDescription(method.frameworkMethod.getMethod().getDeclaringClass(),
             Utils.stringify(paramSet, i) + " (" + method.name() + ")", method.frameworkMethod.getAnnotations()));
             */
     parametrised.addChild(
         Description.createTestDescription(
             method.frameworkMethod.getMethod().getDeclaringClass(),
             method.name() + " [" + i + "]",
             method.frameworkMethod.getAnnotations()));
   }
   return parametrised;
 }
 @Override
 public Description getDescription() {
   Description suiteDescription = createSuiteDescription(testClass);
   suiteDescription.addChild(createTestDescription(testClass, "someTest"));
   return suiteDescription;
 }
 @Override
 public Description getDescription() {
   Description suite = Description.createSuiteDescription(clas);
   filteredTests.foreachDoEffect(p -> suite.addChild(p._3()));
   return suite;
 }