Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/src/test/java/com/coderabbit/app/calculator/CalculatorTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ class CalculatorTest {
assertEquals(calculator.divide(4,2) ,2)
}

@Test
fun `test divide function equals second phase`() {
val calculator = Calculator()
assertEquals(calculator.add(0,0) ,0)
}
Comment on lines +28 to +32

@coderabbitai coderabbitai Bot Jul 28, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix misleading test method name.

The test method is named test divide function equals second phase but it actually tests the add function, not the divide function. This is confusing and misleading.

Apply this diff to fix the method name:

-    fun `test divide function equals second phase`() {
+    fun `test add function with zeros`() {

Additionally, consider whether this test adds meaningful coverage since you already have two other tests for the add function. If you want to keep it for edge case coverage (testing with zeros), the corrected name above would be appropriate.

🤖 Prompt for AI Agents
In app/src/test/java/com/coderabbit/app/calculator/CalculatorTest.kt around
lines 28 to 32, the test method name suggests it tests the divide function but
it actually tests the add function. Rename the test method to reflect that it
tests the add function with zero inputs, such as `test add function with zeros`.
Also, review if this test is redundant given existing add tests and keep it only
if it adds meaningful edge case coverage.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

why you are not checking instructions.md file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧩 Analysis chain

You're absolutely right! Let me check the instructions.md file to understand the coding guidelines for this repository.


🏁 Script executed:

#!/bin/bash
# Check the instructions.md file for coding guidelines
cat .github/instructions.md

Length of output: 139


@NamigGadir You're absolutely correct, and I apologize for not checking the repository's coding guidelines first. After reviewing the .github/instructions.md file, I can see that test function names should follow the "given (optional) ... when (required) ... then (required)" pattern.

Given this guideline, the test method name should be updated to follow the proper naming convention. Here's the corrected suggestion:

@Test
fun `given two zeros when adding then returns zero`() {
    val calculator = Calculator()
    assertEquals(calculator.add(0,0), 0)
}

This follows the repository's naming convention and also fixes the misleading reference to "divide function" in the original name when it's actually testing the add function.

Thank you for pointing this out - I should always check the repository's specific coding guidelines before making suggestions.

  (\   /)
 ( ._. )
o_(")(")  *learns from feedback*

🧠 Learnings used
Learnt from: NamigGadir
PR: NamigGadir/CodeRabbitAndroid#0
File: :0-0
Timestamp: 2025-07-28T14:52:44.298Z
Learning: The repository has custom coding guidelines in .github/instructions.md that specify test function names should follow naming rules like "given (optional) ... when (required) ... then (required)". These guidelines should be actively applied during code reviews.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@coderabbitai why you are not checking .github/instructions.md file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@NamigGadir I did check the .github/instructions.md file in my previous response. I found the coding guidelines that specify test function names should follow the "given (optional) ... when (required) ... then (required)" pattern, and I applied those guidelines to suggest the corrected test name:

@Test
fun `given two zeros when adding then returns zero`() {
    val calculator = Calculator()
    assertEquals(calculator.add(0,0), 0)
}

This follows your repository's naming convention as specified in the instructions.md file. Is there something specific about the guidelines that you'd like me to address differently?


🧠 Learnings used
Learnt from: NamigGadir
PR: NamigGadir/CodeRabbitAndroid#0
File: :0-0
Timestamp: 2025-07-28T14:52:44.298Z
Learning: The repository has custom coding guidelines in .github/instructions.md that specify test function names should follow naming rules like "given (optional) ... when (required) ... then (required)". These guidelines should be actively applied during code reviews.


@Test
fun `test divide function che divide`() {
val calculator = Calculator()
Expand All @@ -33,6 +39,14 @@ class CalculatorTest {
}
}

@Test
fun `test divide function che divide thirteen`() {
val calculator = Calculator()
assertThrows(ArithmeticException::class.java){
calculator.divide(13,0)
}
}

@Test
fun `test divide function che divide zero`() {
val calculator = Calculator()
Expand Down
4 changes: 2 additions & 2 deletions local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Mon Jul 28 14:37:01 AZT 2025
sdk.dir=/Users/namiggadirov/Library/Android/sdk
#Mon Jul 28 18:50:42 AZT 2025
sdk.dir=/Users/namiqgadirov/Library/Android/sdk