|
JET | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.utep.cs.et.gui.tester.JUnitExporter
public class JUnitExporter
A utility class to export generated test cases as JUnit tests. The produced JUnit test classes can be compiled and executed independently of the ET tool. This class can be used to export (1) all the test cases of a set of methods, and (2) a chosen set of test cases of a method (refer to the public APIs for details).
| Nested Class Summary | |
|---|---|
private static class |
JUnitExporter.JavaFileFilter
A file filter class to filter out non-java files. |
private static class |
JUnitExporter.NameGenerator
A class to generate unique test method names. |
private static class |
JUnitExporter.SimpleVarGenerator
A class to generate unique variable names. |
| Field Summary | |
|---|---|
private static JFileChooser |
chooser
The file chooser to prompt the user for an output file. |
private Class |
clazz
The class of which test cases are to be exported. |
private File |
file
The output JUnit file to be created. |
private static String |
JMLRT
Package name of the JML runtime. |
private EtMethod |
method
The method of whose test cases, given by the field testcases, are to be exported. |
private List<EtMethod> |
methods
The list of methods of which test cases are to be exported; if null, the set of test cases given by testcases are
exported. |
private JUnitExporter.NameGenerator |
nameGen
A name generator to generate unique names for test methods. |
private static String |
POSTFIX_TEST_CLASS_NAME
Default postfix of the generated test class name. |
private static String |
PREFIX_ORACLE_METHOD_NAME
Prefix of the generated test oracle method names. |
private static String |
PREFIX_TEST_METHOD_NAME
Prefix of the generated test method names. |
private EtTestCase[] |
testcases
The set of test cases to be exported; if null, all the test cases of the methods methods are exported. |
| Constructor Summary | |
|---|---|
protected |
JUnitExporter(EtTestCase[] testcases,
File file)
Creates a JUnit exporter to export the given set of test cases of the given method to the given file. |
protected |
JUnitExporter(List<EtMethod> methods,
File file)
Creates a JUnit exporter to export all the test cases of the given method to the given file. |
| Method Summary | |
|---|---|
private static String |
capitalize(String s)
Returns a capitalized version of the argument. |
void |
export()
Exports test cases as a JUnit test class. |
static void |
export(EtTestCase[] testcases,
File dir)
Exports the given test cases of the given method as JUnit tests. |
static void |
export(List<EtMethod> methods,
File dir)
Exports all the test cases of the given methods as JUnit tests. |
private void |
exportTestCases(File file)
Exports test cases to the given file. |
private static String |
getClassName(File file)
Returns the class name corresponding to the given Java file. |
private String |
getOracleMethodNameFor(EtMethod meth)
Returns a unique oracle method name for the given method. |
private Class[] |
getParameterTypes(EtMethod meth)
Returns the parameter types of the given method or constructor. |
private static String |
getSimpleClassName(Class clazz)
Returns the simple name of the given class. |
private String |
getTestMethodNameFor(EtMethod meth)
Returns a unique test method name for the given method. |
private static File |
promptForOutputFile(Class clazz,
File dir)
Prompts the user for the file name of the JUnit test class to be generated for the given class, returns the file; returns null if the file can't be created or the user aborts. |
private void |
writeBoilerPlateMethods(BufferedWriter out,
String clazz)
Writes boiler-plate test methods. |
private void |
writeOracleMethod(BufferedWriter out,
EtMethod meth)
Writes the test oracle method for the given method. |
private void |
writeTestCases(BufferedWriter out,
EtMethod meth)
Writes test methods for the given method. |
private void |
writeTestCases(BufferedWriter out,
EtMethod meth,
EtTestCase[] testcases)
Writes test methods for the given method. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final String PREFIX_TEST_METHOD_NAME
private static final String PREFIX_ORACLE_METHOD_NAME
private static final String POSTFIX_TEST_CLASS_NAME
private static final String JMLRT
private JUnitExporter.NameGenerator nameGen
private Class clazz
private List<EtMethod> methods
testcases are
exported.
testcases,
methodprivate EtTestCase[] testcases
methods are exported. The test
cases are assumed to be for the same method, method.
methodsprivate EtMethod method
testcases, are to be exported.
testcasesprivate File file
private static JFileChooser chooser
| Constructor Detail |
|---|
protected JUnitExporter(List<EtMethod> methods,
File file)
protected JUnitExporter(EtTestCase[] testcases,
File file)
| Method Detail |
|---|
public static void export(List<EtMethod> methods,
File dir)
public static void export(EtTestCase[] testcases,
File dir)
public void export()
throws IOException
IOException
private static File promptForOutputFile(Class clazz,
File dir)
private static String getSimpleClassName(Class clazz)
String of java.lang.String.
private void exportTestCases(File file)
throws IOException
IOException
private void writeBoilerPlateMethods(BufferedWriter out,
String clazz)
throws IOException
IOException
private void writeOracleMethod(BufferedWriter out,
EtMethod meth)
throws IOException
IOExceptionprivate Class[] getParameterTypes(EtMethod meth)
private void writeTestCases(BufferedWriter out,
EtMethod meth)
throws IOException
IOException
private void writeTestCases(BufferedWriter out,
EtMethod meth,
EtTestCase[] testcases)
throws IOException
IOExceptionprivate String getTestMethodNameFor(EtMethod meth)
private String getOracleMethodNameFor(EtMethod meth)
private static String capitalize(String s)
private static String getClassName(File file)
|
JET | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||