Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main dependencies updated #496

Merged
merged 1 commit into from
Dec 1, 2023
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
strategy:
matrix:
mock-maker: ['mock-maker-default', 'mock-maker-inline']
kotlin: ['1.3.50', '1.4.21']
kotlin: ['1.9.20']
# Note that the old Travis CI referenced other Kotlin versions: '1.0.7', '1.1.61', '1.2.50'
# However, those versions of Kotlin don't work with latest Gradle

Expand Down
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)
TimvdLippe marked this conversation as resolved.
Show resolved Hide resolved
}

@Test
Expand Down
Loading