Esempio n. 1
0
 /**
  * This is for troubleshooting suite failures by running a subset of tests within a suite without
  * requiring any Java or Gosu code changes
  */
 private void restrictTestSpecsToSpecifiedNames() {
   String includedTests = System.getProperty(GOSU_SUITE_INCLUDE_TYPES);
   if (includedTests != null) {
     System.out.println(
         "System property "
             + GOSU_SUITE_INCLUDE_TYPES
             + " used, so only running tests specified:");
     System.out.println(includedTests);
     String[] includedTestsArray = includedTests.replace(" ", "").split(",");
     HashSet<String> includedTestSet = new HashSet<String>(Arrays.asList(includedTestsArray));
     for (Iterator<TestSpec> it = _testSpecs.iterator(); it.hasNext(); ) {
       TestSpec spec = it.next();
       if (!includedTestSet.contains(spec.getTestType().getName())) {
         it.remove();
       }
     }
   }
 }
Esempio n. 2
0
  private void maybeCreateTestClassWrappers() {

    maybeInitSuite();

    if (!_testClassWrappersCreated) {
      long start = System.currentTimeMillis();

      if (_testSpecs.isEmpty()) {
        TestClassFinder finder =
            new TestClassFinder(_iFileFilters, _packageFilters, _withPackages, _typeFilters);
        _testSpecs.addAll(finder.findTests(_gosuClassSearchPath, _javaClassSearchPath));
      }

      restrictTestSpecsToSpecifiedNames();

      for (TestSpec spec : _testSpecs) {
        if (_testEnvironment.isRemoteExecutionEnvironment()) {
          String[] methods = spec.runAllMethods() ? null : spec.getMethods();
          RemoteTestClassWrapper remoteWrapper =
              new RemoteTestClassWrapper(_executionManager, spec.getTestTypeName(), methods);
          addTest(remoteWrapper);
        } else {
          IType type = spec.getTestType();
          addTest(new TestClassWrapper(_executionManager, type, spec.getMethods()));
        }
      }
      _testClassWrappersCreated = true;
      long end = System.currentTimeMillis();
      System.out.println("Test wrappers created in " + (end - start) + "ms");

      if (_testEnvironment.isDynamicallyDeterminedEnvironment()) {
        _testEnvironment = determineTestEnvironmentBasedOnTestDefaults();
        System.out.println(
            "Dynamically determined the test environment to be " + _testEnvironment.getClass());
        // This is pretty hacky, but RemoteTestEnvironments need a chance to tell the remote server
        // what sort of environment to set up, and that actually needs to be done prior to beginning
        // the suite
        if (_testEnvironment instanceof ForwardingTestEnvironment) {
          _testEnvironment.initializeTypeSystem();
        }
        _executionManager.setEnvironment(_testEnvironment);
      }
    }
  }