How to Use Grading Tests
So, you’ve submitted an assignment, and you desperately want to know how you did… well, good news! Grading takes a while on my end, but you can get a sneak preview by running the grading tests yourself. These are the exact tests I run against your code when I grade it.
How to Get Grading Tests
Grading tests are released some time after an assignment’s due date. Once they’re out, a link appears at the top of that assignment’s instructions page:
Homework 1 Grading Tests
Click it and your browser downloads a .zip file (for example, homework1.zip). Inside is a src folder laid out exactly like the src folder in your repository. Usually it holds only test files, but sometimes I include extra helper classes the tests need (Homework 2, for instance, includes some extra Forneymon species).
Adding Them to Your Project
The goal is to get every file from the zip’s src folder into the same folder in your repository’s src. The grading test files have different names from the tests you were given (e.g., FinanceUtilsGradingTests.java instead of FinanceUtilsTests.java), so they sit alongside your existing files. They won’t replace any of them.
Don't drag folders onto folders
Do not drag the zip’s
test(ormain) folder onto thetestfolder in your repository. On a Mac in particular, Finder will offer to replace your folder, which deletes everything already in it, including your own code and tests. Use one of the two options below instead.
Option 1: The terminal (recommended)
Move the downloaded zip into the root folder of your repository (the folder that contains src), open a terminal there, and run:
macOS / Linux / Git Bash:
unzip homework1.zipWindows PowerShell:
Expand-Archive homework1.zip -DestinationPath . -ForceBoth of these merge the files into your existing src folder without touching anything else. Swap in the name of the zip you actually downloaded. You can delete the zip afterward.
Option 2: By hand
Unzip the file anywhere (double-click it), then open the unzipped src folder and find each .java file inside it. Drag each file (not the folder around it) into the matching package in IntelliJ’s Project panel. For example, src/test/util/financeutils/FinanceUtilsGradingTests.java goes into the test.util.financeutils package. If IntelliJ asks whether to refactor or update references, just click OK without changing anything.
When you’re done, the grading tests should appear in IntelliJ right next to the tests you already had.
Running Grading Tests
Running the grading tests works just like running your other tests in IntelliJ:
- To run a single test class, open it and click the green ▶ arrow next to the class name, or right-click the file and choose Run.
- To run everything at once, right-click the
testpackage in the Project panel and choose Run ‘Tests in ‘test”.
IntelliJ’s Run panel shows each test passing (green) or failing (red). Click a failed test to see what it expected and what your code actually produced.
Tip
A failing grading test tells you exactly what I’ll be marking down, so it’s well worth reading the test’s code to see what case you missed!
There’s no need to commit the grading tests to your repository. I add my own copy when I grade, so it makes no difference either way.