Skip to content
Merged
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
25 changes: 25 additions & 0 deletions app/src/test/java/com/coderabbit/app/calculator/CalculatorTest.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.coderabbit.app.calculator

import org.junit.Assert.assertEquals
import org.junit.Assert.assertThrows
import org.junit.Assert.assertTrue
import org.junit.Test

Expand All @@ -23,4 +24,28 @@ class CalculatorTest {
val calculator = Calculator()
assertEquals(calculator.divide(4,2) ,2)
}

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

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

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

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

Fix test name logic and consider reducing duplication.

The test name test divide function che divide zero by 17 is backwards - the code divides 17 by 0, not zero by 17.

Apply this diff to fix the test name:

-    fun `test divide function che divide zero by 17`() {
+    fun `test divide function throws exception when dividing seventeen by zero`() {
🤖 Prompt for AI Agents
In app/src/test/java/com/coderabbit/app/calculator/CalculatorTest.kt around
lines 44 to 50, the test name incorrectly states "divide zero by 17" while the
code divides 17 by 0. Rename the test function to accurately reflect the
operation being tested, such as "test divide function divides 17 by zero". Also,
review the test class for similar test name inconsistencies and consider
extracting common setup code to reduce duplication.

}