Package randoop.test

Class CompilableTestPredicate

java.lang.Object
randoop.test.CompilableTestPredicate
All Implemented Interfaces:
Closeable, AutoCloseable, Predicate<ExecutableSequence>

public class CompilableTestPredicate extends Object implements Closeable, Predicate<ExecutableSequence>
TestPredicate that returns true if the given ExecutableSequence is compilable.
  • Field Details

    • compiler

      private final SequenceCompiler compiler
      The compiler for sequence code.
    • junitCreator

      private final JUnitCreator junitCreator
      The JUnitCreator to generate a class from a ExecutableSequence
    • classNameGenerator

      private final NameGenerator classNameGenerator
      The name generator for temporary class names.
    • methodNameGenerator

      private final NameGenerator methodNameGenerator
      The name generator for test method names.
    • genTests

      private final GenTests genTests
      The GenTests instance that created this predicate.
  • Constructor Details

    • CompilableTestPredicate

      public CompilableTestPredicate(JUnitCreator junitCreator, GenTests genTests)
      Creates a predicate using the given JUnitCreator to construct the test class for each sequence.
      Parameters:
      junitCreator - the JUnitCreator for this Randoop run
      genTests - the GenTests instance to report compilation failures
  • Method Details

    • close

      public void close() throws IOException
      Releases resources held by this.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • test

      public boolean test(ExecutableSequence eseq)

      Indicate whether the given sequence is compilable.

      Specified by:
      test in interface Predicate<ExecutableSequence>
      Returns:
      true if the sequence can be compiled, false otherwise
    • testSource

      boolean testSource(String testClassName, com.github.javaparser.ast.CompilationUnit source, String packageName)
      Return true if the given source code compiles without error. This is here to allow the mechanics of the predicate to be tested directly. Otherwise, we have to create a broken ExecutableSequence, which may not always be possible.
      Parameters:
      testClassName - the name of the test class
      source - the source text for the class
      packageName - the package name for the test, null if no package
      Returns:
      true if the code compiles (without error), false otherwise