I am currently using an online system running in Google App Engine to enable students to practice coding in python. The system is inspired by codingbat by Nick Parlante and the public version of Beanshell running on appengine.
I would like to extend our system to support Java. In our current system, the Python doctest feature makes it very easy for instructors to type out a series of variable declarations and doctests which can then be executed against student-submitted code. It is very intuitive for the instructors which is important to ensure lots of people are writing tests.
How do I replace the following comments with Java code to eval and execute tests in Java?
String solution = “a=1;”;
solution += “b=1;”;
String problem = “self.assertEqual(a,1);”;
problem += “c=3;”;
problem += “self.assertEqual(b,2);”;
//eval the solution string
//eval the problem string possibly wrapped by additional junit or other Java code.
//results = Run all the tests
System.out.println(“Test expected received result”);
//For result in results
// print test, expected, received, result(pass/fail)
Desired output:
Test expected received result
self.assertEqual(a,1) 1 1 pass
self.assertEqual(b,2) 2 1 fail
Ideally any number of tests could be included in the problem string above and any number of Java statements could be included in the solution string in order to pass the tests included in the problem string.