Skip to content

Code Coverage#643

Draft
mewilker wants to merge 36 commits into
mainfrom
398-code-coverage-grading
Draft

Code Coverage#643
mewilker wants to merge 36 commits into
mainfrom
398-code-coverage-grading

Conversation

@mewilker

Copy link
Copy Markdown
Contributor

Overview

Resolves #398. NOTE: this PR should not be merged until all other instruction has been updated and we are ready to start grading students on this requirement.

This PR changes how unit tests are graded, rather than counting numbers of tests, it evaluates the coverage on an area of source code that is relevant to the phase. The formula for grading is (student coverage / expected coverage). The idea is that unit tests are now graded on quality not quantity.

Details

  • Changed unit test grader to use coverage to caluclate scores
  • Added a verifier to ensure student code is in the correct spots to collect coverage, sends a warning if not
  • Penalty config now takes in configurable code coverage requirements
  • Rubric config sql statements have been changed to outline current expected coverage requirements (changing tables is probably not necessary for developers)

Testing

  • Added/updated unit tests
  • Tested edge cases
  • Manual testing (if needed)

Dependencies

The softwareconstruction repository with the instruction should be changed at the same time this goes into effect.

Future Work

Dr. Wilkerson has stated that we still may want to scan the code for bogus test assertions.

Additional Notes

Big shout out to @ZakkeryDaRebel for taking responsibility over this for a short while and @19mdavenport for writing the code that actually collects the coverage.

mewilker and others added 30 commits November 12, 2025 00:10
…tring so that nothing is removed from the coverage results if it is not Phase 3-4.
…ed line coverage checking if not for unitTests.
# Conflicts:
#	src/main/java/edu/byu/cs/autograder/test/TestGrader.java
#	src/main/java/edu/byu/cs/autograder/test/TestHelper.java
…e files showing if they have good coverage or not
@mewilker mewilker self-assigned this May 22, 2026
@mewilker mewilker linked an issue May 22, 2026 that may be closed by this pull request

@19mdavenport 19mdavenport left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if my feedback is wanted, but I noticed a couple of things that may be helpful.

In addition to the other two comments on lines, I noticed in several places you added the coverage config stuff to the "penalty" section in the config. I understand you may not want to add a whole new config endpoint, request, and other things, but do the code coverage settings qualify as penalties?

Comment on lines +83 to +85
if (coveragePercent > extraCreditPercent) {
return 1.05F;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might you want the extra credit to be configurable from the frontend as well, rather than hardcoding it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extraCreditPercent is configurable! If it can't grab it from the dao though it defaults to 90%

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait did you mean the score?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did

Comment thread src/main/java/edu/byu/cs/autograder/test/UnitTestGrader.java Outdated
@mewilker

Copy link
Copy Markdown
Contributor Author

I don't know if my feedback is wanted, but I noticed a couple of things that may be helpful.

In addition to the other two comments on lines, I noticed in several places you added the coverage config stuff to the "penalty" section in the config. I understand you may not want to add a whole new config endpoint, request, and other things, but do the code coverage settings qualify as penalties?

I'll take your feedback!

I figured they could qualify as penalties because if they don't reach a certain coverage their score is penalized :)

@ZakkeryDaRebel ZakkeryDaRebel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides my question about the Extra Credit portion, my version of the autograder did not work as expected.

I submitted my Phase 3 code to the autograder, and with line got 80.2%, and with branch I got 77%. This gave me extra credit version of the grade (26.25/25). Then when I went into the config and changed the percentages to be 80% for full points and 90% for extra credit, my 80.2% line coverage instead gave me 22.38/25, or about 90% of the points instead of full points.

I'll take a look at the code if there aren't any students coming in about what is causing this issue, but thought I would point out the problem and see if anyone else is experiencing issues.

EDIT: I realized that I had accidentally changed both to 90%, so that's why I only got 90% of the points that time around.


return testResults.getNumTestsPassed() / totalTests;
if (coveragePercent >= extraCreditPercent) {
return 1.05F;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we want to use the Extra Credit Rubric set up by DavSmasher instead of returning 1.05, or is it just handled in this one spot?

@ZakkeryDaRebel

Copy link
Copy Markdown
Contributor

You know what, ignore my prior message altogether. The first problem was because I didn't update the configuration in my database, so it defaulted to the extra credit and target percentage to be 0%, which I do indeed pass and get the extra credit. Then the second problem was I mistyped to update the percentages.

TLDR; the code works, my comment was just a user error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backend: Add some verification of student test cases

3 participants