Skip to content

tests added - #9

Merged
NamigGadir merged 1 commit into
mainfrom
tech/add_new_tests_file
Jul 29, 2025
Merged

tests added#9
NamigGadir merged 1 commit into
mainfrom
tech/add_new_tests_file

Conversation

@NamigGadir

@NamigGadir NamigGadir commented Jul 29, 2025

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Tests
    • Added a new unit test to verify division by zero handling in the calculator.
    • Added an additional unit test to the example test suite.

@coderabbitai

coderabbitai Bot commented Jul 29, 2025

Copy link
Copy Markdown

Walkthrough

Two new unit test methods were added: one in the ExampleUnitTest class that always passes, and another in the CalculatorTest class that verifies dividing 20 by 0 throws an ArithmeticException. No production code or logic was changed.

Changes

Cohort / File(s) Change Summary
ExampleUnitTest Add Test
app/src/test/java/com/coderabbit/app/ExampleUnitTest.java
Added addition_isFalse test method with a passing assertion (assertTrue(true)).
CalculatorTest Division by Zero
app/src/test/java/com/coderabbit/app/calculator/CalculatorTest.kt
Added test method to assert that dividing 20 by 0 throws ArithmeticException.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • add tests #7: Adds a similar division-by-zero test for dividing 14 by 0 in CalculatorTest, directly related to this PR's new test.
  • Tech/add new tests zeor #5: Adds multiple division-by-zero test cases in CalculatorTest, overlapping in focus with this PR.
  • calculator tests #3: Adds an addition test to CalculatorTest.kt, modifying the same test class as this PR.

Poem

A bunny hops in test delight,
New checks for code, both day and night!
One test says "true," it cannot fail,
The other guards division's trail.
With every hop, our tests grow strong—
🐇💡 Quality all along!


🪧 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 sequence diagram to generate a sequence diagram of the changes in 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: 2

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6ea8c9a and ec94ede.

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

Comment on lines +52 to +58
@Test
fun `test divide function che divide zero by twenty`() {
val calculator = Calculator()
assertThrows(ArithmeticException::class.java){
calculator.divide(20,0)
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove duplicate division-by-zero test.

This test is functionally identical to the existing division-by-zero tests (lines 29-34, 37-42, 45-50). Testing division by zero with different dividends doesn't provide additional value since the behavior should be consistent regardless of the dividend.

Consider removing this duplicate test:

-    @Test
-    fun `test divide function che divide zero by twenty`() {
-        val calculator = Calculator()
-        assertThrows(ArithmeticException::class.java){
-            calculator.divide(20,0)
-        }
-    }

The existing division-by-zero tests already provide adequate coverage for this edge case.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Test
fun `test divide function che divide zero by twenty`() {
val calculator = Calculator()
assertThrows(ArithmeticException::class.java){
calculator.divide(20,0)
}
}
🤖 Prompt for AI Agents
In app/src/test/java/com/coderabbit/app/calculator/CalculatorTest.kt around
lines 52 to 58, remove the duplicate test function that checks division by zero
with dividend 20, as this case is already covered by existing tests on lines
29-50. Deleting this redundant test will keep the test suite concise without
losing coverage.

Comment on lines +18 to +21
@Test
public void addition_isFalse() {
assertTrue(true);
}

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

Remove or fix this meaningless test.

This test method has several issues:

  • The method name addition_isFalse is misleading and doesn't match what's being tested
  • assertTrue(true) is a trivial assertion that always passes and provides no testing value
  • The test doesn't verify any actual functionality

Either remove this test or replace it with a meaningful test:

-    @Test
-    public void addition_isFalse() {
-        assertTrue(true);
-    }
+    @Test
+    public void addition_isIncorrect() {
+        assertNotEquals(5, 2 + 2);
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Test
public void addition_isFalse() {
assertTrue(true);
}
@Test
public void addition_isIncorrect() {
assertNotEquals(5, 2 + 2);
}
🤖 Prompt for AI Agents
In app/src/test/java/com/coderabbit/app/ExampleUnitTest.java around lines 18 to
21, the test method addition_isFalse is misleading and trivial because it
asserts true unconditionally. Replace this test with a meaningful one that
verifies actual functionality or remove it entirely if it serves no purpose.

@NamigGadir

Copy link
Copy Markdown
Owner Author

@coderabbitai why you are not reading instructions file?

@coderabbitai

coderabbitai Bot commented Jul 29, 2025

Copy link
Copy Markdown

Tip

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for any files that might contain instructions
echo "=== Searching for instruction-related files ==="
fd -t f -i "readme|contributing|instructions|guide|docs" --exclude node_modules --exclude .git

echo ""
echo "=== Searching for files with 'instruction' in the name ==="
fd -t f -i "instruction" --exclude node_modules --exclude .git

echo ""
echo "=== Looking for any markdown files that might contain instructions ==="
fd -t f -e md --exclude node_modules --exclude .git

echo ""
echo "=== Checking root directory for common instruction files ==="
ls -la | grep -E "(README|CONTRIBUTING|INSTRUCTIONS|GUIDE)"

Length of output: 876


🏁 Script executed:

#!/bin/bash
# Read the instructions.md file
echo "=== Reading instructions.md file ==="
cat instructions.md

Length of output: 214


@NamigGadir You're absolutely right, and I apologize for that oversight. I should have proactively searched for and read the instructions.md file in your repository before reviewing the code.

After reading it now, I can see you have a specific naming convention for test functions: they should follow the pattern "given (optional) ... when (required) ... then (required)".

Looking at the test methods added in this PR, they don't follow this convention:

  1. addition_isFalse() in ExampleUnitTest.java
  2. test divide function che divide zero by twenty() in CalculatorTest.kt

These should be renamed following your naming rules, for example:

  • addition_isFalse()when_addition_is_performed_then_result_is_correct() or similar
  • test divide function che divide zero by twenty()when_dividing_by_zero_then_arithmetic_exception_is_thrown()

I'll make sure to always check for instruction files in repositories going forward. Thank you for pointing this out!


✏️ Learnings added
Learnt from: NamigGadir
URL: https://github.com/NamigGadir/CodeRabbitAndroid/pull/9

Timestamp: 2025-07-29T05:02:55.403Z
Learning: In the NamigGadir/CodeRabbitAndroid repository, test function names should follow the naming convention "given (optional) ... when (required) ... then (required)" as specified in the instructions.md file.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@NamigGadir
NamigGadir merged commit 4bb331c into main Jul 29, 2025
2 checks passed
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