Skip to content

add tests - #6

Merged
NamigGadir merged 2 commits into
mainfrom
tech/test-naming-checks
Jul 28, 2025
Merged

add tests#6
NamigGadir merged 2 commits into
mainfrom
tech/test-naming-checks

Conversation

@NamigGadir

@NamigGadir NamigGadir commented Jul 28, 2025

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Tests

    • Added new tests to verify calculator addition and division error handling.
  • Chores

    • Updated configuration files with new timestamp and SDK directory path.

@coderabbitai

coderabbitai Bot commented Jul 28, 2025

Copy link
Copy Markdown

Walkthrough

Two new test methods were added to the CalculatorTest class: one verifies that adding 0 and 0 returns 0, and the other asserts that dividing 13 by 0 throws an ArithmeticException. The local.properties file was updated with a new timestamp and a corrected SDK directory path.

Changes

Cohort / File(s) Change Summary
CalculatorTest Update
app/src/test/java/com/coderabbit/app/calculator/CalculatorTest.kt
Added two test methods: one to assert Calculator.add(0, 0) returns 0, and another to verify division by zero throws ArithmeticException.
Local Properties Update
local.properties
Updated timestamp comment and corrected the SDK directory path.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • test added #1: Introduces the initial CalculatorTest class and its tests, forming the base for added test coverage in this PR.
  • calculator tests #4: Adds the divide method and related tests in CalculatorTest, closely related to the division tests added here.
  • Tech/add new tests zeor #5: Adds tests for divide-by-zero scenarios in CalculatorTest, overlapping in functionality with this PR’s division-by-zero test.

Poem

In the warren of code, a new test appears,
Checking that zero plus zero brings no fears.
Division by zero, a trap we now spy,
Throws an exception—no silent goodbye.
Properties updated, the SDK path is right,
Our calculator’s logic shines ever so bright.
Hippity-hop, our tests now grow—
Onward, dear coder, let the green checks show! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03a55da and fcfc6f3.

📒 Files selected for processing (1)
  • app/src/test/java/com/coderabbit/app/calculator/CalculatorTest.kt (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/src/test/java/com/coderabbit/app/calculator/CalculatorTest.kt
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tech/test-naming-checks

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
local.properties (1)

1-9: Remove this file from version control.

The file explicitly states it "must NOT be checked into Version Control Systems" as it contains local configuration specific to your development environment. Including local.properties in a PR violates this principle and can cause build issues for other developers.

Add this file to .gitignore and remove it from the repository:

+# Remove from repository
+git rm --cached local.properties
+
+# Add to .gitignore if not already present
+echo "local.properties" >> .gitignore
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd34c75 and 03a55da.

📒 Files selected for processing (2)
  • app/src/test/java/com/coderabbit/app/calculator/CalculatorTest.kt (1 hunks)
  • local.properties (1 hunks)

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

@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.

@NamigGadir

Copy link
Copy Markdown
Owner Author

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

@coderabbitai

coderabbitai Bot commented Jul 28, 2025

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

@NamigGadir I should indeed be checking the .github/instructions.md file as it contains the project's coding guidelines. Let me examine it now to understand what guidelines I should be applying to this PR.


🏁 Script executed:

#!/bin/bash
# Read the coding guidelines from .github/instructions.md
cat .github/instructions.md

Length of output: 139


@NamigGadir You're absolutely right! I should be actively checking and applying the coding guidelines from .github/instructions.md.

Looking at the current changes, the new test method test divide function equals second phase violates the naming convention specified in your guidelines. According to .github/instructions.md, test function names should follow the pattern: given (optional) ... when (required) ... then (required).

The current test name should be refactored to follow this convention. For example:

fun `when adding zero and zero then returns zero`() {
    // Test implementation
}

or with a given clause:

fun `given calculator instance when adding zero and zero then returns zero`() {
    // Test implementation
}

I apologize for missing this in my initial review. I'll make sure to consistently check and apply the coding guidelines from .github/instructions.md for all future reviews, especially for test naming conventions.


🧠 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.

@NamigGadir
NamigGadir merged commit e932306 into main Jul 28, 2025
2 checks passed
This was referenced Jul 28, 2025
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.

1 participant