Let's say we have a Calculator class, which performs simple arithmetic operations. We want to write tests for this class using the MockK framework to check that the class is working correctly.
MockK
CalculatorTest implementation
Report a typo
Reorder lines using drag or arrows. Adjust indentation with left buttons
val calculator = mockk<Calculator>()
}
fun testAddition() {
}
class CalculatorTest {
every { calculator.add(2, 3) } returns 5
@Test
assertEquals(5, calculator.add(2, 3))
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.