Skip to content

Commit 7d9aa80

Browse files
timis1timis1
andauthored
JAVA-32740 Reorganize modules kotlin-testing 1,2 (#944)
Co-authored-by: timis1 <[email protected]>
1 parent 9986314 commit 7d9aa80

24 files changed

+69
-73
lines changed

kotlin-mockito/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Core Kotlin Testing
2+
3+
This module contains articles about testing in Kotlin
4+
5+
### Relevant articles:
6+
- [Mock Static Java Methods Using Mockk](https://www.baeldung.com/kotlin/mockk-mock-static-methods)
7+
- [Mockk – Check If a Method Was Not Invoked](https://www.baeldung.com/kotlin/mockk-check-method-invoked)
8+
- [Matching Varargs Using MockK in Kotlin](https://www.baeldung.com/kotlin/mockk-matching-varargs)
9+
- [Kotlin with Mockito](https://www.baeldung.com/kotlin/mockito)
10+
- [Testing a Lambda Function With Mockito Kotlin](https://www.baeldung.com/kotlin/mockito-verify-lambda)
11+
- [MockK: A Mocking Library for Kotlin](https://www.baeldung.com/kotlin/mockk)
12+
- [How to Mock and Verify Lambda Expression in Kotlin](https://www.baeldung.com/kotlin/lambda-mock-verify)
13+
- [Using Spy in MockK](https://www.baeldung.com/kotlin/mockk-spy)

kotlin-mockito/pom.xml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<artifactId>kotlin-mockito</artifactId>
7+
<name>kotlin-mockito</name>
8+
<packaging>jar</packaging>
9+
10+
<parent>
11+
<groupId>com.baeldung</groupId>
12+
<artifactId>kotlin-modules</artifactId>
13+
<version>1.0.0-SNAPSHOT</version>
14+
</parent>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>com.nhaarman</groupId>
19+
<artifactId>mockito-kotlin</artifactId>
20+
<version>${nhaarman-mockito-kotlin.version}</version>
21+
<scope>test</scope>
22+
</dependency>
23+
<dependency>
24+
<groupId>org.mockito.kotlin</groupId>
25+
<artifactId>mockito-kotlin</artifactId>
26+
<version>${mockito-kotlin.version}</version>
27+
<scope>test</scope>
28+
</dependency>
29+
<!-- MockK dependencies-->
30+
<dependency>
31+
<groupId>io.mockk</groupId>
32+
<artifactId>mockk</artifactId>
33+
<version>${mockk.version}</version>
34+
<scope>test</scope>
35+
</dependency>
36+
<dependency>
37+
<groupId>io.mockk</groupId>
38+
<artifactId>mockk-jvm</artifactId>
39+
<version>${mockk.version}</version>
40+
<scope>test</scope>
41+
</dependency>
42+
</dependencies>
43+
44+
<properties>
45+
<nhaarman-mockito-kotlin.version>1.5.0</nhaarman-mockito-kotlin.version>
46+
<mockito-kotlin.version>5.1.0</mockito-kotlin.version>
47+
<mockk.version>1.13.3</mockk.version>
48+
</properties>
49+
</project>

kotlin-testing/src/test/kotlin/com/baeldung/lambdamocks/MockAndVerifyLambdasTest.kt renamed to kotlin-mockito/src/test/kotlin/com/baeldung/lambdamocks/MockAndVerifyLambdasTest.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import kotlin.test.assertEquals
1111

1212
class CalculatorUnitTest {
1313

14-
class Calculator(private val operation: (Int, Int) -> Int) {
15-
fun calculate(a: Int, b: Int): Int {
16-
return operation(a, b)
17-
}
18-
}
14+
class Calculator(private val operation: (Int, Int) -> Int) {
15+
fun calculate(a: Int, b: Int): Int {
16+
return operation(a, b)
17+
}
18+
}
1919
@Test
2020
fun testLambda_WithMockito() {
2121
val operationMock: (Int, Int) -> Int = mock()
@@ -42,6 +42,4 @@ class CalculatorUnitTest {
4242
val result = calculator.calculate(10, 5)
4343
assertEquals(50, result)
4444
verify { operationMock(10, 5) } }
45-
}
46-
47-
45+
}

0 commit comments

Comments
 (0)