Skip to content
Open
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
4 changes: 4 additions & 0 deletions app/src/main/java/com/coderabbit/app/calculator/Calculator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ class Calculator {
fun divide(a: Int, b: Int): Int {
return a/b
}

fun minus(a: Int, b: Int): Int {
return a - b
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,10 @@ class CalculatorTest {
calculator.divide(20,0)
}
}

@Test
fun `test minus function be correct`() {
val calculator = Calculator()
assertEquals(calculator.minus(4,2) ,2)
}
Comment on lines +91 to +95

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 test to comply with coding guidelines.

The test violates the coding guidelines in two ways:

  1. Uses @Test annotation instead of required @CustomTest
  2. 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.

}