Skip to content

🧪 [Add edge case tests for performanceLevel mapping] - #192

Closed
alvin000009238 wants to merge 1 commit into
mainfrom
test-performance-level-edge-cases-2595319409649776547
Closed

🧪 [Add edge case tests for performanceLevel mapping]#192
alvin000009238 wants to merge 1 commit into
mainfrom
test-performance-level-edge-cases-2595319409649776547

Conversation

@alvin000009238

Copy link
Copy Markdown
Owner

🎯 What
Added missing edge case tests for the performanceLevel mapping function in GradeAnalysis.kt. To enable testing, the function's visibility was updated from private to internal.

📊 Coverage
Tests now explicitly verify all boundary conditions for the topPercent calculation, ensuring each branch of the when expression 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 performanceLevel mapping 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

Co-authored-by: alvin000009238 <107313913+alvin000009238@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 17, 2026 14:32
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist gemini-code-assist Bot 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.

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 {

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.

medium

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.

Suggested change
internal fun performanceLevel(topPercent: Int): String = when {
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal fun performanceLevel(topPercent: Int): String = when {

Copilot AI 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.

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 performanceLevel visibility from private to internal to 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.

@alvin000009238
alvin000009238 deleted the test-performance-level-edge-cases-2595319409649776547 branch July 9, 2026 09:30
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.

2 participants