As an CS instructor, my solution for that was to have a skeleton level of unit tests but to switch in a full suite once the deadline passed. Your grade was based on passing the full tests.
Practically everyone who "played fair" got the same grade for both. Occasionally, I would add a test that tripped everybody up and I'd have to go see what happened. Anybody who overfitted, however, got crushed.
My favorite assignment was always the next to last project (before end of semester deadlines start getting crushing). I created only a single unit test to verify the test suite runner was functional, and the students had to submit the rest of the pre-deadline unit tests. And I would switch in my full suite at the deadline. I told people that anybody who passed that suite would get bonus points that everybody was always bugging me for.
It was always absolute chaos. I only ever had one student pass the switched in suite (he got some nice bonus points out of that--didn't need them, of course). I would then reopen the project for a week (I planned for it) to let everybody else clean up their work and resubmit.
You could see and feel the difference in the students after that assignment. The fact that testing was an integral part of programming and that testing was, in and of itself, a difficult problem was a revelation--and not a particularly welcome one.
Practically everyone who "played fair" got the same grade for both. Occasionally, I would add a test that tripped everybody up and I'd have to go see what happened. Anybody who overfitted, however, got crushed.
My favorite assignment was always the next to last project (before end of semester deadlines start getting crushing). I created only a single unit test to verify the test suite runner was functional, and the students had to submit the rest of the pre-deadline unit tests. And I would switch in my full suite at the deadline. I told people that anybody who passed that suite would get bonus points that everybody was always bugging me for.
It was always absolute chaos. I only ever had one student pass the switched in suite (he got some nice bonus points out of that--didn't need them, of course). I would then reopen the project for a week (I planned for it) to let everybody else clean up their work and resubmit.
You could see and feel the difference in the students after that assignment. The fact that testing was an integral part of programming and that testing was, in and of itself, a difficult problem was a revelation--and not a particularly welcome one.