Reputation: 12128
I'm a Teaching Assistant for a Java course, and part of my job is to grade about ~100 Java programming assignments each week, each consisting of 3-5 standalone Java programs. The students are provided with a skeletal framework for each problem (which makes the names of packages/classes/methods identical), and all they have to do is to fill in the logic for the methods.
I was wondering what would be the best way to verify all such submissions for correctness, perhaps using JUnit (or similar frameworks) coupled with some script? Before I went ahead and did that, I wanted to know if there are better approaches to actually set up a system, where I would just change the test cases (and corresponding class/method names) and would be able to execute the entire set of assignments?
I'm looking for mainly pointers to a framework that can do this, though I more than welcome detailed solutions/similar instances of an implemented framework!
Upvotes: 0
Views: 224
Reputation: 31648
Since all students have the same package/class and method names. It should be pretty easy to write a JUnit class that tests the methods. All you would need to do is figure out how to hook each student's classes in.
Since you control all the code, I recommend including a factory method or known constructor to create instances each Student's implementations. It might even be possible to use a Dependency Injection Framework like Google Guice to handle the creations for you.
I've never tried it, but Jukito seems promising, it uses Guice to inject directly into your unit tests. However, it looks like they recently moved repositories and haven't updated the wiki links yet ( here is their old project page which at least has code examples)
@RunWith(JukitoRunner.class)
public class Project1Test{
@Inject
Project1 studentImplementation;
@Test
public void testMethod1(){
//...
}
@Test
public void testMethod2DoesntOverflow(){
//...
}
//...
}
}
I would even recommend having a way for the students to run the tests themselves before they submit so they can see if they meet all the requirements and pass all the tests. (of course you would run your own copy of the tests so students don't modify the tests so they always pass no matter what)
If that doesn't work, you can always write a script that does somekind of find/replace to paste in a student's implementation and then recompile and run the code over and over again.
Upvotes: 1
Reputation: 3634
I think I might do it via subversion. Separate directory per assignment. Students check in when they're ready, which triggers a JUnit test to be run.
I'm not sure you can get away without writing code yourself. The unit test would have to figure out whose code it's running, and then run it etc. Not sure if doing it in the unit test, or have jenkins do it would be better though.
Upvotes: 1