🧪 [Add edge case tests for performanceLevel mapping] - #192
Conversation
Co-authored-by: alvin000009238 <107313913+alvin000009238@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Code Review
This pull request changes the visibility of the performanceLevel function from private to internal in GradeAnalysis.kt and adds a corresponding unit test in GradeAnalysisTest.kt. The reviewer suggests annotating the function with @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) to explicitly document that its visibility was relaxed solely for testing purposes.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| } | ||
|
|
||
| private fun performanceLevel(topPercent: Int): String = when { | ||
| internal fun performanceLevel(topPercent: Int): String = when { |
There was a problem hiding this comment.
When relaxing the visibility of a private function to internal for testing purposes, it is highly recommended to annotate it with @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE). This clearly documents the intent that the function's visibility was only increased for testing, and prevents other parts of the codebase from accidentally relying on this internal implementation detail. Note that you may need to import androidx.annotation.VisibleForTesting.
| internal fun performanceLevel(topPercent: Int): String = when { | |
| @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) | |
| internal fun performanceLevel(topPercent: Int): String = when { |
There was a problem hiding this comment.
Pull request overview
This PR improves the reliability of the grade analysis “performance level” labeling by adding explicit unit tests for all topPercent boundary conditions, and adjusts the mapping helper’s visibility so it can be tested from the unit test source set.
Changes:
- Added a new unit test that exercises every branch and boundary of
performanceLevel(topPercent). - Changed
performanceLevelvisibility fromprivatetointernalto allow direct unit testing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| android/app/src/test/java/com/clhs/score/data/GradeAnalysisTest.kt | Adds boundary-condition assertions for performanceLevel outputs at 1/25/26/50/51/75/76/100. |
| android/app/src/main/java/com/clhs/score/data/GradeAnalysis.kt | Makes performanceLevel(topPercent) internal so the new unit test can call it. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🎯 What
Added missing edge case tests for the
performanceLevelmapping function inGradeAnalysis.kt. To enable testing, the function's visibility was updated fromprivatetointernal.📊 Coverage
Tests now explicitly verify all boundary conditions for the
topPercentcalculation, ensuring each branch of thewhenexpression is executed and returns the correct string:班級前段(topPercent <= 25): tested 1, 25中上(topPercent <= 50): tested 26, 50中段(topPercent <= 75): tested 51, 75需要加強(else): tested 76, 100✨ Result
Achieved comprehensive test coverage for the
performanceLevelmapping logic, preventing potential regressions if the boundary logic or return strings are modified in the future.PR created automatically by Jules for task 2595319409649776547 started by @alvin000009238