Add minus function and tests - #16
Conversation
WalkthroughA new Changes
Sequence Diagram(s)sequenceDiagram
participant Test as CalculatorTest
participant Calc as Calculator
Test->>Calc: minus(4, 2)
Calc-->>Test: 2
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Possibly related PRs
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
app/src/main/java/com/coderabbit/app/calculator/Calculator.kt(1 hunks)app/src/test/java/com/coderabbit/app/calculator/CalculatorTest.kt(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/test/**
⚙️ CodeRabbit Configuration File
**/test/**: - test function names should follow naming rules like given (optional) ... when (required) ... then(required)
- test function should be implemented @customTest annotation
Files:
app/src/test/java/com/coderabbit/app/calculator/CalculatorTest.kt
🔇 Additional comments (1)
app/src/main/java/com/coderabbit/app/calculator/Calculator.kt (1)
13-15: LGTM! Clean and correct implementation.The minus method follows the same pattern as the existing methods in the class and correctly implements integer subtraction.
| @Test | ||
| fun `test minus function be correct`() { | ||
| val calculator = Calculator() | ||
| assertEquals(calculator.minus(4,2) ,2) | ||
| } |
There was a problem hiding this comment.
Fix test to comply with coding guidelines.
The test violates the coding guidelines in two ways:
- Uses
@Testannotation instead of required@CustomTest - Test name doesn't follow the "given...when...then" naming pattern
Apply this diff to fix the guideline violations:
- @Test
- fun `test minus function be correct`() {
+ @CustomTest
+ fun `given two integers when subtracting then returns correct difference`() {
val calculator = Calculator()
assertEquals(calculator.minus(4,2) ,2)
}Don't forget to add the import for @CustomTest at the top of the file.
🤖 Prompt for AI Agents
In app/src/test/java/com/coderabbit/app/calculator/CalculatorTest.kt around
lines 91 to 95, replace the @Test annotation with @CustomTest and rename the
test function to follow the "given...when...then" naming pattern, for example,
"givenTwoNumbers_whenMinus_thenCorrectResult". Also, add the import statement
for @CustomTest at the top of the file to ensure the annotation is recognized.
Summary by CodeRabbit
New Features
Tests