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 Summary
Modifier and TypeFieldDescriptionprivate final NameGenerator
The name generator for temporary class names.private final SequenceCompiler
The compiler for sequence code.private final GenTests
TheGenTests
instance that created this predicate.private final JUnitCreator
TheJUnitCreator
to generate a class from aExecutableSequence
private final NameGenerator
The name generator for test method names. -
Constructor Summary
ConstructorDescriptionCompilableTestPredicate
(JUnitCreator junitCreator, GenTests genTests) Creates a predicate using the givenJUnitCreator
to construct the test class for each sequence. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Releases resources held by this.boolean
test
(ExecutableSequence eseq) (package private) boolean
testSource
(String testClassName, com.github.javaparser.ast.CompilationUnit source, String packageName) Return true if the given source code compiles without error.
-
Field Details
-
compiler
The compiler for sequence code. -
junitCreator
TheJUnitCreator
to generate a class from aExecutableSequence
-
classNameGenerator
The name generator for temporary class names. -
methodNameGenerator
The name generator for test method names. -
genTests
TheGenTests
instance that created this predicate.
-
-
Constructor Details
-
CompilableTestPredicate
Creates a predicate using the givenJUnitCreator
to construct the test class for each sequence.- Parameters:
junitCreator
- theJUnitCreator
for this Randoop rungenTests
- theGenTests
instance to report compilation failures
-
-
Method Details
-
close
Releases resources held by this.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
test
Indicate whether the given sequence is compilable.
- Specified by:
test
in interfacePredicate<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 brokenExecutableSequence
, which may not always be possible.- Parameters:
testClassName
- the name of the test classsource
- the source text for the classpackageName
- the package name for the test, null if no package- Returns:
- true if the code compiles (without error), false otherwise
-