SpecCheck Questions

What do students learn by using SpecCheck?

I wish my purpose were so noble. SpecCheck’s raison d’etre is to make grading easier in large lecture classes. By conditioning student code to better conform to the published specification, we graders are more likely to succeed in running functional tests—which only work if the students name things correctly, have the right parameters, and return the right types. Still, according to my informal surveying, SpecCheck has helped my students better understand the technical narratives they’ve encountered in my classes.

Why not just give the students a class that links to all the specified parts of the homework? Deviations will be marked by the compiler.

Yes, you may be able to make this work. It is not a satisfactory solution to me for several reasons:

  1. Errors caused by students’ deviations from the specification appear in my code, not the students’.
  2. Messages produced by the compiler are often indirect and misleading to my first-year students.
  3. It’s hard to test certain things this way, like excessive instance variables, exception clauses, and types that deviate from the specification but may be implicitly coerced by the compiler.
  4. It’s more work. Certainly one can test for conformance this way, but it requires more twiddling and typing than I’d like to spend on such repetitive tasks.

Unit tests are supposed to be small and independent. SpecCheck tests are long and full of many assertions. What gives?

SpecCheck tests aren’t meant to be traditional tests. I didn’t want my students getting flooded with error messages for every one of their deviations all at once. Instead, SpecCheck generates one test method for each specified class. Within each test method there are many assertions, to ensure correct supertypes, correct parameters, correct modifiers, correct return type, and so on. The first failed assertion stops the test and subsequent assertions are not run.

Does SpecCheck work with BlueJ?

Yes. One instructor found it easiest to create a project for her students with the SpecChecker class already included. The generated JUnit tests inside this class are detected by BlueJ and the class is considered a test fixture. Any other methods in the class, including main, are ignored. If you want a main method orchestrating the test execution, put it in a separate class.


Leave a Reply

Your email address will not be published. Required fields are marked *