Beispiel #1
0
  private void matchTestCasesClasses(Collection<CompilationUnit> units)
      throws FileNotFoundException {

    for (CompilationUnit unit : units) {
      for (String baseDir : classesDirs) {
        File classFile = unit.getClassFile(baseDir);
        System.out.println(classFile.getAbsolutePath());
        if (classFile.exists()) {
          unit.setClassFile(classFile);
          break;
        }
      }
      if (unit.getClassFile() == null) {
        throw new FileNotFoundException(
            "Class file for source " + unit.getSourceFile().getAbsolutePath() + " not found");
      }
    }
  }
Beispiel #2
0
  public AnalyzerResults analyzeTestCases() throws IOException {
    Collection<CompilationUnit> units = findTestCasesSources();

    // match test cases sources with class
    matchTestCasesClasses(units);

    List<TestCase> testCases = new ArrayList<TestCase>();
    for (CompilationUnit unit : units) {
      TestCase testCase = new TestCase(unit);
      final File classFile = unit.getClassFile();
      final FileInputStream inputStream = new FileInputStream(classFile);
      TestCaseMethod[] methods = engine.getTestMethods(inputStream);
      testCase.setTestCaseMethods(methods);
      testCases.add(testCase);
    }

    return new AnalyzerResults(testCases);
  }