Skip to content

Commit

Permalink
Main dependencies updated:
Browse files Browse the repository at this point in the history
 - gradle wrapper to 8.1
 - kotlin to 1.9.20
 - mockito-core to version 5.7.0
 - few other related changes
  • Loading branch information
Nynuzoud committed Nov 30, 2023
1 parent ccbb768 commit cc8ed1a
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 43 deletions.
10 changes: 4 additions & 6 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
apply plugin: 'maven-publish'

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
archiveClassifier = 'javadoc'
from 'build/javadoc'
}

task sourceJar(type: Jar) {
archiveClassifier = "sources"
from sourceSets.main.allSource
}

Expand All @@ -17,10 +18,7 @@ publishing {

from components.java

artifact sourceJar {
classifier "sources"
}

artifact sourceJar
artifact javadocJar

pom.withXml {
Expand Down Expand Up @@ -67,4 +65,4 @@ signing {
useInMemoryPgpKeys(System.getenv("PGP_KEY"), System.getenv("PGP_PWD"))
sign publishing.publications.javaLibrary
}
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
39 changes: 21 additions & 18 deletions mockito-kotlin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

apply plugin: 'kotlin'
apply from: '../gradle/publishing.gradle'
apply plugin: 'org.jetbrains.dokka'

buildscript {
ext.kotlin_version = "1.4.20"
ext.kotlin_version = "1.9.20"

repositories {
mavenCentral()
}

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.17"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.9.10"
}
}

Expand All @@ -25,33 +26,35 @@ dependencies {
compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compileOnly 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.0'

compile "org.mockito:mockito-core:5.3.1"
implementation "org.mockito:mockito-core:5.7.0"

testCompile 'junit:junit:4.13.2'
testCompile 'com.nhaarman:expect.kt:1.0.1'
testImplementation 'junit:junit:4.13.2'
testImplementation 'com.nhaarman:expect.kt:1.0.1'

testCompile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
testCompile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0'
testImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0'

testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0"
}

dokka {
outputFormat = 'html'
outputDirectory = "$buildDir/javadoc"
dokkaHtml.configure {
outputDirectory.set(file("$buildDir/javadoc"))

linkMapping {
dir = "src/main/kotlin"
url = "https://github.com/nhaarman/mockito-kotlin/tree/master/mockito-kotlin/src/main/kotlin"
suffix = "#L"
dokkaSourceSets {
named("main") {
localDirectory.set(file("src/main/kotlin"))
remoteUrl.set(new URL("https://github.com/nhaarman/mockito-kotlin/tree/master/mockito-kotlin/src/main/kotlin"))
remoteLineSuffix.set("#L")
}
}
}

tasks.withType(KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
targetCompatibility = "11"
}
}

javadoc.dependsOn dokka
javadoc.dependsOn dokkaHtml
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,4 @@ inline fun <reified T : Any> mock(s: String): T = mock(name = s)

@Suppress("DeprecatedCallableAddReplaceWith")
@Deprecated("Use mock() with optional arguments instead.", level = ERROR)
inline fun <reified T : Any> mock(s: MockSettings): T = Mockito.mock(T::class.java, s)!!
inline fun <reified T : Any> mock(s: MockSettings): T = Mockito.mock(T::class.java, s)!!
22 changes: 14 additions & 8 deletions tests/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

buildscript {
ext.kotlin_version = System.getenv("KOTLIN_VERSION") ?: '1.4.20'
ext.kotlin_version = System.getenv("KOTLIN_VERSION") ?: '1.9.20'
println "$project uses Kotlin $kotlin_version"

repositories {
Expand All @@ -19,18 +20,23 @@ repositories {
mavenCentral()
}

tasks.named('compileTestKotlin') {
dependsOn ':mockito-kotlin:jar'
}

dependencies {
compile files("${rootProject.projectDir}/mockito-kotlin/build/libs/mockito-kotlin-${version}.jar")
implementation files("${rootProject.projectDir}/mockito-kotlin/build/libs/mockito-kotlin-${version}.jar")

compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.mockito:mockito-core:5.3.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.mockito:mockito-core:5.7.0"

testCompile 'junit:junit:4.13.2'
testCompile "com.nhaarman:expect.kt:1.0.1"
testImplementation 'junit:junit:4.13.2'
testImplementation "com.nhaarman:expect.kt:1.0.1"
}

tasks.withType(KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
targetCompatibility = "11"
}
}
26 changes: 17 additions & 9 deletions tests/src/test/kotlin/test/OngoingStubbingTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@ import org.junit.Assume.assumeFalse
import org.junit.Test
import org.mockito.Mockito
import org.mockito.exceptions.misusing.UnfinishedStubbingException
import org.mockito.kotlin.*
import org.mockito.kotlin.any
import org.mockito.kotlin.argThat
import org.mockito.kotlin.check
import org.mockito.kotlin.doAnswer
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.doReturnConsecutively
import org.mockito.kotlin.doThrow
import org.mockito.kotlin.mock
import org.mockito.kotlin.stub
import org.mockito.kotlin.stubbing
import org.mockito.kotlin.whenever
import org.mockito.stubbing.Answer
import kotlin.check

class OngoingStubbingTest : TestBase() {

Expand Down Expand Up @@ -288,14 +297,13 @@ class OngoingStubbingTest : TestBase() {

@Test
fun doReturn_withGenericIntReturnType_on() {
/* Expect */
expectErrorWithMessage("onGeneric") on {

/* When */
mock<GenericMethods<Int>> {
on { genericMethod() } doReturn 2
}
/* When */
val mock = mock<GenericMethods<Int>> {
on { genericMethod() } doReturn 2
}

/* Then */
expect(mock.genericMethod()).toBe(2)
}

@Test
Expand Down

0 comments on commit cc8ed1a

Please sign in to comment.