Missing Methods in Java Code

Missing Methods in Java Code

de către NATHAN JOHNSON-
Număr de răspunsuri: 2

I'm new to coderunner but have used similar autograding systems. When a student writes a class with several methods and one of the methods is missing, the test case for that method causes coderunner to throw a compile time exception -- which means none of the tests compile and run. Is there a way to simply remove points for the missing or misnamed method and continue the other test cases?

Ca răspuns la NATHAN JOHNSON

Re: Missing Methods in Java Code

de către Richard Lobb-
Unfortunately the condition 'compile error' is global to all tests, even if some of the tests would compile ok in isolation.

We generally try to avoid this sort of situation by setting a series of questions asking students to incrementally develop a class. Each new questions defines and tests a single new method. That provides a nice test-as-you-go development strategy for the students.

However, you could achieve what you wanted by turning off the "All-or-nothing" checkbox and using reflection in your test cases. For example if students are asked to write a class Bunkum with two method "hi" and "ho", you could test those methods with test-case code like

 
Bunkum bun = new Bunkum();
try {
    var hiMethod = Bunkum.class.getMethod("hi");
    hiMethod.invoke(bun); // Call bun.hi()
} catch (ReflectiveOperationException e) {
    System.out.println("Unimlemented 'hi'. Test aborted.");
}
and
 
Bunkum bun = new Bunkum();
try {
    var hoMethod = Bunkum.class.getMethod("ho");
    hoMethod.invoke(bun); // Call bun.ho
} catch (ReflectiveOperationException e) {
    System.out.println("Unimlemented 'ho'. Test aborted");
}

It would also be possible to develop a new question type that used a combinator grader to take complete control of the compile-and-run-tests process, but that's guru territory.

Ca răspuns la Richard Lobb

Re: Missing Methods in Java Code

de către NATHAN JOHNSON-
Thank you! I was thinking of using reflection but wanted to make sure there wasn't an easier way. I'm still unsure whether that will abort all tests or just the one that's not implemented; in any case I'll give it a try. Thank you very much.