|
UTJML | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.utep.cs.utjml.rat.TestClassGenerator
public class TestClassGenerator
A class for generating JML/JUnit test driver classes.
An object of this class can generate a JML/JUnit test oracle class
from an object of JCompilationUnit.
| Nested Class Summary | |
|---|---|
protected class |
TestClassGenerator.MethodsIterator
A composite control abstraction useful in this class. |
protected static class |
TestClassGenerator.NameGenerator
A class for generating unique names for test methods. |
| Field Summary | |
|---|---|
protected boolean |
includeInherited
Indicates whether tests are generated for all the inherited methods too. |
protected String |
packageString
The name of the package the generated class is in. |
protected String |
testClassName
The test class name currently being generated. |
protected String |
testedPackageString
The name of the package the type being tested is in. |
protected JTypeDeclarationType |
typeDecl
The type declaration currently being translated. |
| Fields inherited from interface edu.utep.cs.utjml.rat.Constants |
|---|
DOT_JAVA, PKG_JMLRAC, PKG_JMLUNIT, PKG_JUNIT, TEST_CLASS_FILE_NAME_POSTFIX, TEST_CLASS_NAME_POSTFIX, TEST_DATA_FILE_NAME_POSTFIX, TEST_DATA_NAME_POSTFIX, TEST_METHOD_NAME_PREFIX |
| Constructor Summary | |
|---|---|
TestClassGenerator(RatOptions options)
Constructs a new test oracle generator. |
|
| Method Summary | |
|---|---|
protected String |
capitalize(String s)
Return a capitalized version of the argument |
protected void |
composeFailMessage(MethodInfo mdecl,
String mname,
edu.utep.cs.utjml.rat.Parameter[] params,
edu.utep.cs.utjml.rat.Parameter receiver,
boolean isInstance,
boolean isConstructor)
Generates code that composes a message about the method and parameters. |
protected void |
composeMessage(String method,
edu.utep.cs.utjml.rat.Parameter[] params,
boolean isInstance,
boolean isConstructor)
Generates code that composes a message about the method and parameters. |
protected void |
generateTestClass(JCompilationUnit cunit,
JTypeDeclarationType cdecl)
Generates a test oracle class for the given class declaration, cdecl. |
protected void |
generateTestMethod(MethodInfo mdecl)
Generates and prints a test method for the given method declaration, mdecl. |
protected String |
getPackageString()
return the package string, if present. |
protected String |
getTestedPackageString()
return the package string, if present. |
protected void |
indent()
Indents one TAB_SIZE. |
protected static boolean |
isStatic(long modifiers)
Returns true if the argument has a static modifier. |
protected String |
methodSig(MethodInfo mdecl)
|
protected TestClassGenerator.MethodsIterator |
methodsIter()
Return a new methods iterator for the methods that should be checked. |
protected void |
newLine()
Prints a line separator. |
void |
perform(Writer writer,
JCompilationUnit cunit,
RatOptions options)
Generates a JML/JUnit test oracle class for the given compilation unit. |
protected void |
print(Object s)
Prints the given object. |
protected void |
print(String s)
Prints the given string. |
protected void |
printClassHeader()
Prints the class header of test oracle class. |
protected void |
printClassJavadoc()
Prints a javadoc comment for the current class. |
protected void |
printConstructor()
Prints a boilerplate constructor. |
protected void |
printFileHeader()
Prints a file header message. |
protected void |
println(Object s)
Prints the given object with a trailing line separator. |
protected void |
printlnIn(Object s)
Prints the given object with one TAB_SIZE indentation and a trailing line separator. |
protected void |
printMain()
Prints a boilerplate main method. |
protected void |
printSuite()
Prints a boilerplate suite method. |
protected void |
printTestMethods()
Generates and prints test methods for all testable methods in the current class delcaration. |
protected String |
testMethodName(String ident)
Returns a unique test method name for the given method name. |
protected void |
undent()
Und-ndents one TAB_SIZE. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected JTypeDeclarationType typeDecl
protected String testClassName
invariant typeDecl != null ==> testClassName.equals(typeDecl.ident() + TEST_CLASS_NAME_POSTFIX);
protected String packageString
protected String testedPackageString
protected final boolean includeInherited
| Constructor Detail |
|---|
public TestClassGenerator(RatOptions options)
| Method Detail |
|---|
public void perform(Writer writer,
JCompilationUnit cunit,
RatOptions options)
requires cunit != null && writer != null;
protected void printFileHeader()
protected void printClassJavadoc()
protected void printClassHeader()
protected void generateTestClass(JCompilationUnit cunit,
JTypeDeclarationType cdecl)
cdecl.
protected TestClassGenerator.MethodsIterator methodsIter()
protected void printTestMethods()
protected void generateTestMethod(MethodInfo mdecl)
mdecl.
protected String methodSig(MethodInfo mdecl)
protected void composeMessage(String method,
edu.utep.cs.utjml.rat.Parameter[] params,
boolean isInstance,
boolean isConstructor)
protected void printConstructor()
protected void printMain()
protected void printSuite()
protected String getPackageString()
protected String getTestedPackageString()
protected void composeFailMessage(MethodInfo mdecl,
String mname,
edu.utep.cs.utjml.rat.Parameter[] params,
edu.utep.cs.utjml.rat.Parameter receiver,
boolean isInstance,
boolean isConstructor)
protected String capitalize(String s)
protected String testMethodName(String ident)
protected static final boolean isStatic(long modifiers)
protected final void indent()
protected final void undent()
protected void print(Object s)
protected void print(String s)
protected void println(Object s)
protected void printlnIn(Object s)
protected void newLine()
|
UTJML | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||