Ejemplo n.º 1
0
  /**
   * Removes test cases from the test suite. The test cases to be removed are derived from the
   * includes and excludes collections contained in the test suite info object.
   *
   * @param suite - The test suite
   * @param testCases - The list of test cases to consider
   */
  private static void removeTestCases(TestSuiteInfo suite, List<ITestCaseDescriptor> testCases) {
    final Collection<String> includes = suite.getTestCaseIncludes();
    final Collection<String> excludes = suite.getTestCaseExcludes();
    final int includesSize = includes.size();
    final int excludesSize = excludes.size();

    assert Conditionals.implies(includesSize > 0, excludesSize == 0);
    assert Conditionals.implies(excludesSize > 0, includesSize == 0);

    /*
     * Handle the include test cases by removing test cases by removing test
     * case that are NOT in the includes set.
     */
    if (includesSize > 0) {
      final Comparator comp =
          new Comparator() {
            public int compare(
                final String currentTestCaseId, final Collection<String> testCaseIds) {
              int comparison = 0;
              for (String testCaseId : testCaseIds) {
                comparison += currentTestCaseId.equals(testCaseId) ? 1 : 0;
              }
              return comparison;
            }
          };
      removeTestCaseDescriptors(testCases, includes, comp);
    }

    /*
     * Handle the excludes test cases by removing the test cases specified in
     * the exclude set.
     */
    if (excludesSize > 0) {
      final Comparator comp =
          new Comparator() {
            public int compare(
                final String currentTestCaseId, final Collection<String> testCaseIds) {
              for (String testCaseId : testCaseIds) {
                if (currentTestCaseId.equals(testCaseId)) {
                  return 0;
                }
              }
              return 1;
            }
          };
      removeTestCaseDescriptors(testCases, excludes, comp);
    }
  }