public class TestEngine
extends Object
Copy TestEngine and TestSuite to package where solution resides. Add package statement to each as necessary.
Write test methods in TestSuite.
Set path variable so that expectedResults.txt will be located in the package. If using Eclipse, path="src\\soln_package\\" is probably what you want.
Set shouldGenerateExpectedResults=true
Run. This generates expectedResults.txt and also displays it to the console.
Set shouldGenerateExpectedResults=false
Run. You are grading the solution, thus, examine the console which shows the studentReport and make sure everything looks correct. If not, repeat these steps.
Copy TestEngine, TestSuite, and expectedResults.txt to package where student solution resides. Add package statement to each as necessary.
Set path variable so that expectedResults.txt will be located in the package. If using Eclipse, path="src\\student_package\\" is probably what you want.
Set shouldGenerateExpectedResults=false
Run. This generates studentReport.txt and also displays it to the console
Modifier and Type | Field and Description |
---|---|
(package private) File |
expectedResultsFile |
(package private) GradeReport |
gradeReport |
(package private) String |
path
Path to location where student assessment summary should be saved if
shouldSaveStudentReport=true . |
(package private) boolean |
shouldGenerateExpectedResults
Set to
true when generating expected results by running against the solution. |
(package private) boolean |
shouldSaveStudentReport
Set to
true to save assessment summary from running against student solution. |
(package private) File |
studentReportFile |
Constructor and Description |
---|
TestEngine() |
Modifier and Type | Method and Description |
---|---|
private void |
addActualResults(ArrayList<ArrayList<String>> resultsLists)
Adds the list of results from running against the student solution (actual results) to
the
GradeReport |
private GradeReport |
buildExpectedGradeReport(ArrayList<ArrayList<String>> resultsLists)
Builds the
GradeReport holding the expected results when running against the solution. |
private void |
generateActualResults()
Runs against student solution, assesses against expected results and displays a summary.
|
private void |
generateExpectedResults()
Builds and saves the expected results by running program against the solution.
|
private ArrayList<ArrayList<String>> |
generateTestResults()
Run the test case methods.
|
static void |
main(String[] args)
Program either (a) generates and saves the expected results or (b) generates, assesses and saves
the actual results from running against the student solution.
|
private ArrayList<ArrayList<String>> |
readExpectedResults(File file)
Read the expected results that are saved in
file |
private void |
saveResults(String results,
File file)
Saves a text file.
|
private ArrayList<String> |
testMethodNames()
Gets the names of the test case methods in
TestSuite |
GradeReport gradeReport
boolean shouldGenerateExpectedResults
true
when generating expected results by running against the solution.
Set to false
when running against a student solution. Must have expected results file.boolean shouldSaveStudentReport
true
to save assessment summary from running against student solution. This is
optional because it always displays to console.String path
shouldSaveStudentReport=true
.
Can ignore if set to false
File studentReportFile
File expectedResultsFile
private void generateExpectedResults()
private void generateActualResults()
private ArrayList<String> testMethodNames()
TestSuite
private ArrayList<ArrayList<String>> generateTestResults()
ArrayList<String>
of results. This return is the collection of all these lists.private GradeReport buildExpectedGradeReport(ArrayList<ArrayList<String>> resultsLists)
GradeReport
holding the expected results when running against the solution.resultsLists
- the list of expected results from each test case method when running
against the solution.private void addActualResults(ArrayList<ArrayList<String>> resultsLists)
GradeReport
resultsLists
- the list of actual results from each test case method when running
against the student solution.private ArrayList<ArrayList<String>> readExpectedResults(File file)
file
file
- contains the expected resultsprivate void saveResults(String results, File file)
results
- either the expected results or the GradeReport
summary from
running against the student solution.file
- public static void main(String[] args)
args
-