| java.lang.Object de.uka.ilkd.key.unittest.TestGenerator
TestGenerator | public class TestGenerator (Code) | | Generates a unittest for a given piece of code and a set of modelgenerators.
|
Method Summary | |
public static Statement | assignmentOrSet(Expression lhs, Expression rhs, Services serv) Generates either an assignment statement lhs = rhs; or a method call
statement for the appropriate set method in the case that
lhs is a field reference. | public Expression | convertToProgramElement(Term t) Converts t to a ProgramElement. | public void | exportCodeUnderTest() Exports the code under test to files and adds get and set methods for
each field. | public void | generateTestSuite(Statement[] code, Term oracle, List mgs, SetOfProgramVariable programVars, String methodName, PackageReference pr) Generates the testcase and writes it to a file.
Parameters: code - the piece of code that is tested by the generated unittest. Parameters: oracle - a term representing the postcondition of code . | public MethodReference | getOracle(Term post, ProgramVariable buffer, ExtList children) Creates a testoracle from the term post .
Parameters: post - the term used for creating a testoracle. Parameters: buffer - a program variable of type StringBuffer. Parameters: children - the children of the enclosing class. | public String | getPath() Returns the path of the file generated by this instance. | public SetOfProgramVariable | removeDublicates(SetOfProgramVariable pvs) | protected static Term | replaceConstants(Term t, Services serv, Namespace newPVs) Replaces rigid constants by program variables. |
counter | static int counter(Code) | | |
TestGenerator | public TestGenerator(Services serv, String fileName)(Code) | | creates a TestGenerator instance for the given compilation unit
Parameters: serv - the Services Parameters: fileName - the name of the unittest file this TestGenerator creates. |
assignmentOrSet | public static Statement assignmentOrSet(Expression lhs, Expression rhs, Services serv)(Code) | | Generates either an assignment statement lhs = rhs; or a method call
statement for the appropriate set method in the case that
lhs is a field reference.
|
convertToProgramElement | public Expression convertToProgramElement(Term t)(Code) | | Converts t to a ProgramElement. If t is
a (skolem)constant, a new identically named ProgramVariable of the
same sort is returned.
|
exportCodeUnderTest | public void exportCodeUnderTest()(Code) | | Exports the code under test to files and adds get and set methods for
each field.
|
generateTestSuite | public void generateTestSuite(Statement[] code, Term oracle, List mgs, SetOfProgramVariable programVars, String methodName, PackageReference pr)(Code) | | Generates the testcase and writes it to a file.
Parameters: code - the piece of code that is tested by the generated unittest. Parameters: oracle - a term representing the postcondition of code . It is used to create a testoracle. Parameters: mgs - List of ModelGenerators. Parameters: programVars - program variables that have to be declared in the method. Parameters: methodName - the name of the testmethod created for code within the test case. |
getOracle | public MethodReference getOracle(Term post, ProgramVariable buffer, ExtList children)(Code) | | Creates a testoracle from the term post .
Parameters: post - the term used for creating a testoracle. Parameters: buffer - a program variable of type StringBuffer. Parameters: children - the children of the enclosing class. The MethodDeclarations created by this method are added to children . |
getPath | public String getPath()(Code) | | Returns the path of the file generated by this instance.
|
removeDublicates | public SetOfProgramVariable removeDublicates(SetOfProgramVariable pvs)(Code) | | |
|
|