Junit Test with CodeRunner

Re: Junit Test with CodeRunner

by Richard Lobb -
Number of replies: 0

It sounds like you're pretty new to CodeRunner so it's probably best if you put the idea of a JUnit question type on hold until you've had a bit more experience. The prototype I gave you was something I threw together as in a hurry, but it's a rather difficult example and not a good starting point for learning. Furthermore, I just looked at it and saw a silly coding error which would give exactly the output you're getting if the test or program failed to compile. I've replaced the attachment in the the original post with a bug-fixed version, and I attach the updated version to this posting, too. You must delete the existing prototype before importing the new .xml or you'll get a prototype error. However, it's still not going to be useful in its present form, so I don't think it's worth proceeding until you're up to speed with writing templates, template debugging, defining new question types and a heap of other complexities. My apologies for tossing such a demanding exercise at you.

If you really really wish to proceed anyway, you'll need to read all the documentation on writing templates and authoring new question types. The example I gave you uses a combinator template grader, the most difficult type. The error message you're getting suggests that the program isn't generating any output, which is exactly what would happen with the first version I posted if anything went wrong (even a compile error - I had tested handling of compile errors while developing but made a last minute change which broke things).

To debug and develop the question type further (are you sure you want to do this?) you will need to proceed as follows:

  1. Create an empty directory for testing. Download the two support files from the prototype (hamcrest_core and junit 4.13 beta) into that directory.
  2. In the test question (calculator, or whatever), turn on the Template debugging checkbox. 
  3. Run the test question (i.e. preview it and click Check).
  4. Copy the Debug source code from the run (assuming only one run took place) into a file tester.py within the test directory you set up.
  5. Run tester.py (you'll need python3 installed to run it). The output should be a JSON string containing the mark in an attribute fraction and the test output in an attribute prologuehtml.
  6. Debug as required.
  7. Copy the corrections back into the prototype's template, but make sure you don't clobber the Twig code that inserts the student's answer into the template.

Good luck.

Richard