Fix problem with empty testcase from DataProvider.

@param array     $cases
@param TestSuite $suite
499985
protected function extendEmptyCasesFromSuites(array $cases, TestSuite $suite)
    {
        $class = $suite->name;
        $file = $suite->file;

        /** @var TestCase $case */
        foreach ($cases as $case) {
            if (empty($case->class)) {
                $case->class = $class;
            }
            if (empty($case->file)) {
                $case->file = $file;
            }
        }
    }
862226
protected function appendCase(\DOMElement $suiteNode, TestCase $case): \DOMElement
    {
        $caseNode = $this->document->createElement('testcase');
        $vars = get_object_vars($case);
        foreach ($vars as $name => $value) {
            if (preg_match(static::$caseAttrs, $name)) {
                if ($this->isEmptyLineAttribute($name, $value)) {
                    continue;
                }
                $caseNode->setAttribute($name, (string) $value);
            }
        }
        $suiteNode->appendChild($caseNode);
        $this->appendDefects($caseNode, $case->failures, 'failure');
        $this->appendDefects($caseNode, $case->errors, 'error');

        return $caseNode;
    }
525204
public void afterSuite(String suiteName, String ... testGroups) {
        testSuiteListener.onFinish();

        if (!CollectionUtils.isEmpty(afterSuite)) {
            for (SequenceAfterSuite sequenceAfterSuite : afterSuite) {
                try {
                    if (sequenceAfterSuite.shouldExecute(suiteName, testGroups)) {
                        sequenceAfterSuite.execute(createTestContext());
                    }
                } catch (Exception e) {
                    testSuiteListener.onFinishFailure(e);
                    throw new AssertionError("After suite failed with errors", e);
                }
            }

            testSuiteListener.onFinishSuccess();
        } else {
            testSuiteListener.onFinishSuccess();
        }
    }
322281
def write_unitth(suites, out_dir):
        
        if not os.path.isdir(out_dir):
            os.mkdir(out_dir)

        for classname, cases in suites.items():
            doc_xml = minidom.Document()

            suite_xml = doc_xml.createElement('testsuite')
            suite_xml.setAttribute('name', classname)
            suite_xml.setAttribute('tests', str(len(cases)))
            suite_xml.setAttribute('errors', str(sum('error' in case for case in cases)))
            suite_xml.setAttribute('failures', str(sum('failure' in case for case in cases)))
            suite_xml.setAttribute('skipped', str(sum('skipped' in case for case in cases)))
            suite_xml.setAttribute('time', '{:.3f}'.format(sum(case['time'] for case in cases)))
            doc_xml.appendChild(suite_xml)

            for case in cases:
                case_xml = doc_xml.createElement('testcase')
                case_xml.setAttribute('classname', classname)
                case_xml.setAttribute('name', case['name'])
                case_xml.setAttribute('time', '{:.3f}'.format(case['time']))
                suite_xml.appendChild(case_xml)

                if 'skipped' in case:
                    skipped_xml = doc_xml.createElement('skipped')
                    skipped_xml.setAttribute('type', case['skipped']['type'])
                    skipped_xml.setAttribute('message', case['skipped']['message'])
                    case_xml.appendChild(skipped_xml)

                    skipped_text_xml = doc_xml.createCDATASection(case['skipped']['text'])
                    skipped_xml.appendChild(skipped_text_xml)

                if 'failure' in case:
                    failure_xml = doc_xml.createElement('failure')
                    failure_xml.setAttribute('type', case['failure']['type'])
                    failure_xml.setAttribute('message', case['failure']['message'])
                    case_xml.appendChild(failure_xml)

                    failure_text_xml = doc_xml.createCDATASection(case['failure']['text'])
                    failure_xml.appendChild(failure_text_xml)

                if 'error' in case:
                    error_xml = doc_xml.createElement('error')
                    error_xml.setAttribute('type', case['error']['type'])
                    error_xml.setAttribute('message', case['error']['message'])
                    case_xml.appendChild(error_xml)

                    error_text_xml = doc_xml.createCDATASection(case['error']['text'])
                    error_xml.appendChild(error_text_xml)

            with open(os.path.join(out_dir, '{}.xml'.format(classname)), 'w') as output:
                doc_xml.writexml(output, encoding='utf-8', addindent='', newl="")
            doc_xml.unlink()
994984
def prepare_suite(self, suite):
        """"""
        all_tests = {}
        for s in suite:
            m = re.match(r'(\w+)\s+\(.+\)', str(s))
            if m:
                name = m.group(1)
            else:
                name = str(s).split('.')[-1]
            all_tests[name] = s

        return self.orderTests(all_tests, suite)
214891
def start
      suite = TestSuite.new
      testruns = @config.files.collect do |file|
        name = file.sub(Dir.pwd+'/','')
        suite.new_case(name, file)
      end
      test_loop_runner(suite)
    end
94071
function Suite(title, ctx) {
  this.title = title;
  this.ctx = ctx;
  this.suites = [];
  this.tests = [];
  this.pending = false;
  this._beforeEach = [];
  this._beforeAll = [];
  this._afterEach = [];
  this._afterAll = [];
  this.root = !title;
  this._timeout = 2000;
  this._slow = 75;
  this._bail = false;
}
383730
def _run_suite suite, type
      # suites are cases in minitest
      @turn_case = @turn_suite.new_case(suite.name)

      filter = normalize_filter(@options[:filter]) || @turn_config.pattern || /./

      suite.send("#{type}_methods").grep(/#{filter}/).each do |test|
        @turn_case.new_test(test)
      end

      turn_reporter.start_case(@turn_case)

      header = "#{type}_suite_header"
      puts send(header, suite) if respond_to? header

      assertions = @turn_case.tests.map do |test|
        @turn_test = test
        turn_reporter.start_test(@turn_test)

        inst = suite.new(test.name) #method
        inst._assertions = 0

        result = inst.run self

        if result == "."
          turn_reporter.pass
        end

        turn_reporter.finish_test(@turn_test)

        inst._assertions
      end

      @turn_case.count_assertions = assertions.inject(0) { |sum, n| sum + n }

      turn_reporter.finish_case(@turn_case)

      return assertions.size, assertions.inject(0) { |sum, n| sum + n }
    end
446227
private List<String> loadBalanceSuites(List<ForkedJvmInfo> jvmInfo,
      TestsCollection testsCollection, List<SuiteBalancer> balancers) {
    
    // Order test suites identically for balancers.
    // and split into replicated and non-replicated suites.
    Map<Boolean,List<String>> partitioned = sortAndSplitReplicated(testsCollection.testClasses);

    Collection<String> replicated = partitioned.get(true);
    Collection<String> suites     = partitioned.get(false);

    final List<SuiteBalancer> balancersWithFallback = new ArrayList<>(balancers);
    balancersWithFallback.add(new RoundRobinBalancer());

    // Go through all the balancers, the first one to assign a suite wins.
    final List<String> remaining = new ArrayList<>(suites);
    Collections.sort(remaining);

    final Map<Integer,List<Assignment>> perJvmAssignments = new HashMap<>();
    for (ForkedJvmInfo si : jvmInfo) {
      perJvmAssignments.put(si.id, new ArrayList<Assignment>());
    }
    final int jvmCount = jvmInfo.size();
    for (SuiteBalancer balancer : balancersWithFallback) {
      balancer.setOwner(this);
      final List<Assignment> assignments =
          balancer.assign(
              Collections.unmodifiableCollection(remaining), jvmCount, masterSeed());

      for (Assignment e : assignments) {
        if (e == null) {
          throw new RuntimeException("Balancer must return non-null assignments.");
        }
        if (!remaining.remove(e.suiteName)) {
          throw new RuntimeException("Balancer must return suite name as a key: " + e.suiteName);
        }

        log(String.format(Locale.ROOT,
            "Assignment hint: J%-2d (cost %5d) %s (by %s)",
            e.slaveId,
            e.estimatedCost,
            e.suiteName,
            balancer.getClass().getSimpleName()), Project.MSG_VERBOSE);

        perJvmAssignments.get(e.slaveId).add(e);
      }
    }

    if (remaining.size() != 0) {
      throw new RuntimeException("Not all suites assigned?: " + remaining);
    }

    if (shuffleOnSlave) {
      // Shuffle suites on slaves so that the result is always the same wrt master seed
      // (sort first, then shuffle with a constant seed).
      for (List<Assignment> assignments : perJvmAssignments.values()) {
        Collections.sort(assignments);
        Collections.shuffle(assignments, new Random(this.masterSeed()));
      }
    }

    // Take a fraction of suites scheduled as last on each slave and move them to a common
    // job-stealing queue.
    List<SuiteHint> stealingQueueWithHints = new ArrayList<>();
    for (ForkedJvmInfo si : jvmInfo) {
      final List<Assignment> assignments = perJvmAssignments.get(si.id);
      int moveToCommon = (int) (assignments.size() * dynamicAssignmentRatio);

      if (moveToCommon > 0) {
        final List<Assignment> movedToCommon = 
            assignments.subList(assignments.size() - moveToCommon, assignments.size());
        for (Assignment a : movedToCommon) {
          stealingQueueWithHints.add(new SuiteHint(a.suiteName, a.estimatedCost));
        }
        movedToCommon.clear();
      }

      final ArrayList<String> slaveSuites = (si.testSuites = new ArrayList<>());
      for (Assignment a : assignments) {
        slaveSuites.add(a.suiteName);
      }
    }

    // Sort stealing queue according to descending cost.
    Collections.sort(stealingQueueWithHints, SuiteHint.DESCENDING_BY_WEIGHT);

    // Append all replicated suites to each forked JVM, AFTER we process the stealing queue
    // to enforce all replicated suites run on each bound JVM.
    if (!replicated.isEmpty()) {
      for (ForkedJvmInfo si : jvmInfo) {
        for (String suite : replicated) {
            si.testSuites.add(suite);
        }
        if (shuffleOnSlave) {
          // Shuffle suites on slaves so that the result is always the same wrt master seed
          // (sort first, then shuffle with a constant seed).
          Collections.shuffle(si.testSuites, new Random(this.masterSeed()));
        }
      }
    }

    // Dump scheduling information.
    for (ForkedJvmInfo si : jvmInfo) {
      log("Forked JVM J" + si.id + " assignments (after shuffle):", Project.MSG_VERBOSE);
      for (String suiteName : si.testSuites) {
        log("  " + suiteName, Project.MSG_VERBOSE);
      }
    }

    log("Stealing queue:", Project.MSG_VERBOSE);
    for (SuiteHint suiteHint : stealingQueueWithHints) {
      log("  " + suiteHint.suiteName + " " + suiteHint.cost, Project.MSG_VERBOSE);
    }

    List<String> stealingQueue = new ArrayList<>(stealingQueueWithHints.size());
    for (SuiteHint suiteHint : stealingQueueWithHints) {
      stealingQueue.add(suiteHint.suiteName);
    }
    return stealingQueue;
  }
187792
protected function caseNodesToSuiteProperties(array $nodeArray, array &$testCases = [])
    {
        $cb = [TestCase::class, 'caseFromNode'];

        return array_reduce($nodeArray, function ($result, $c) use (&$testCases, $cb) {
            $testCases[] = \call_user_func_array($cb, [$c]);
            $result['name'] = (string) $c['class'];
            $result['file'] = (string) $c['file'];
            ++$result['tests'];
            $result['assertions'] += (int) $c['assertions'];
            $result['failures'] += \count($c->xpath('failure'));
            $result['errors'] += \count($c->xpath('error'));
            $result['skipped'] += \count($c->xpath('skipped'));
            $result['time'] += (float) $c['time'];

            return $result;
        }, static::$defaultSuite);
    }
1286203
public function runSuite( $settings, $suite, $test = null ) {
		$suiteManager = new SuiteManager( $this->dispatcher, $suite, $settings );
		$suiteManager->initialize();
		$suiteManager->loadTests( $test );
		$suiteManager->run( $this->runner, $this->result, $this->options );

		return $this->result;
	}
1257045
public static function build(\PHPUnit_Framework_TestCase $testCase, $config = [])
    {
        $mock = static::get($testCase, $config);

        return $mock->buildMock();
    }
136005
def _run_suites suites, type
      # Someone want to explain to me why these are fucking here?
      suites = suites - [MiniTest::Spec]
      suites = suites - [Test::Unit::TestCase] if defined?(Test::Unit::TestCase)

      @turn_suite = Turn::TestSuite.new(@turn_config.suite_name)
      @turn_suite.size = suites.size  #::MiniTest::Unit::TestCase.test_suites.size
      @turn_suite.seed = ::MiniTest::Unit.runner.options[:seed]

      turn_reporter.start_suite(@turn_suite)

      if @turn_config.matchcase
        suites = suites.select{ |suite| @turn_config.matchcase =~ suite.name }
      end

      result = suites.map { |suite| _run_suite(suite, type) }

      turn_reporter.finish_suite(@turn_suite)

      return result
    end
319170
private function randomizeSuiteThatContainsOtherSuites($suite, $seed)
    {
        $order = 0;
        foreach ($suite->tests() as $test) {
            if ($test instanceof \PHPUnit\Framework\TestSuite && $this->testSuiteContainsOtherSuites($test)) {
                $this->randomizeSuiteThatContainsOtherSuites($test, $seed);
            }
            if ($test instanceof \PHPUnit\Framework\TestSuite) {
                $this->randomizeSuite($test, $seed, $this->order);
            }
            $this->order++;
        }
        return $this->randomizeSuite($suite, $seed, $this->order, false);
    }
130146
protected function appendSuite(\DOMElement $root, TestSuite $suite): \DOMElement
    {
        $suiteNode = $this->document->createElement('testsuite');
        $vars = get_object_vars($suite);
        foreach ($vars as $name => $value) {
            if (preg_match(static::$suiteAttrs, $name)) {
                $suiteNode->setAttribute($name, (string) $value);
            }
        }
        $root->appendChild($suiteNode);

        return $suiteNode;
    }
1311213
public function beforeSuite(SuiteEvent $event)
    {
        if (!$this->enabled) {
            return;
        }

        $filter = $this->coverage->filter();

        array_map(
            [$filter, 'addDirectoryToWhitelist'],
            $this->options['whitelist']
        );
        array_map(
            [$filter, 'removeDirectoryFromWhitelist'],
            $this->options['blacklist']
        );
        array_map(
            [$filter, 'addFileToWhitelist'],
            $this->options['whitelist_files']
        );
        array_map(
            [$filter, 'removeFileFromWhitelist'],
            $this->options['blacklist_files']
        );
    }
1094034
public function beforeSuite(SuiteTested $event)
    {
        $suite = $event->getSuite();

        $testsuite = $this->xml->addChild('testsuite');
        $testsuite->addAttribute('name', $suite->getName());
        $testsuite->addAttribute('tests', 0);
    }