Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into add_jdk_19_to_test_…
Browse files Browse the repository at this point in the history
…matrix
  • Loading branch information
aSemy committed Sep 28, 2022
2 parents 985c6fe + 159a50a commit 51dac76
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 30 deletions.
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,56 +71,55 @@ Table of contents:

All you need to get started is just to add a dependency to `MockK` library.

#### Gradle/maven dependency
#### Gradle/Maven dependency

<table>
<thead><tr><th>Approach</th><th>Instruction</th></tr></thead>
<tr>
<td><img src="doc/gradle.png" alt="Gradle"/></td>
<td>
   <pre>testImplementation "io.mockk:mockk:{version}"</pre>
</td>
<pre>
testImplementation "io.mockk:mockk:${mockkVersion}"
</pre>
</td>
</tr>
<tr>
<td><img src="doc/gradle.png" alt="Gradle"/> (Kotlin DSL)</td>
<td>
   <pre>testImplementation("io.mockk:mockk-jvm:{version}")</pre>
</td>
<td>
<pre>testImplementation("io.mockk:mockk:${mockkVersion}")</pre>
</td>
</tr>
<tr>
<td><img src="doc/maven.png" alt="Maven"/></td>
<td>
<pre>&lt;dependency&gt;
&lt;groupId&gt;io.mockk&lt;/groupId&gt;
&lt;artifactId&gt;mockk-jvm&lt;/artifactId&gt;
   &lt;version&gt;{version}&lt;/version&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;</pre>
</td>
<pre>
&lt;dependency&gt;
&lt;groupId&gt;io.mockk&lt;/groupId&gt;
&lt;artifactId&gt;mockk-jvm&lt;/artifactId&gt;
&lt;version&gt;${mockkVersion}&lt;/version&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;
</pre>
</td>
</tr>
<tr>
<td><a href="ANDROID.md"><img align="top" src="doc/robot-small.png" height="20" alt="android"/> Unit</a></td>
<td>
<pre>
testImplementation "io.mockk:mockk-android:{version}"
testImplementation "io.mockk:mockk-agent-jvm:{version}"
testImplementation "io.mockk:mockk-android:${mockkVersion}"
testImplementation "io.mockk:mockk-agent:${mockkVersion}"
</pre>
</td>
</tr>
<tr>
<td><a href="ANDROID.md"><img align="top" src="doc/robot-small.png" height="20" alt="android"/> Instrumented</a></td>
<td>
<pre>
androidTestImplementation "io.mockk:mockk-android:{version}"
androidTestImplementation "io.mockk:mockk-agent-jvm:{version}"
androidTestImplementation "io.mockk:mockk-android:${mockkVersion}"
androidTestImplementation "io.mockk:mockk-agent:${mockkVersion}"
</pre>
</td>
</tr>
<tr>
<td>Common multiplatform</td>
<td>
   <pre>testImplementation "io.mockk:mockk-common:{version}"</pre>
</td>
</tr>
</table>

## DSL examples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ internal class ProxyMaker(
} else if (interfaces.isEmpty() && !Modifier.isAbstract(clazz.modifiers) && inliner != null) {
log.trace("Taking instance of $clazz itself because it is not abstract and no additional interfaces specified.")
clazz
} else if (clazz.kotlin.isSealed) {
log.trace("Taking instance of subclass of $clazz because it is sealed.")
clazz.kotlin.sealedSubclasses.firstNotNullOfOrNull {
@Suppress("UNCHECKED_CAST")
subclass(it.java, interfaces) as Class<T>
} ?: error("Unable to create proxy for sealed class $clazz, available subclasses: ${clazz.kotlin.sealedSubclasses}")
} else {
log.trace(
"Building subclass proxy for $clazz with " +
Expand Down Expand Up @@ -143,7 +149,7 @@ internal class ProxyMaker(
val defaultConstructor = cls.getDeclaredConstructor()
try {
defaultConstructor.isAccessible = true
} catch (ex: Exception) {
} catch (ignored: Exception) {
// skip
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ package io.mockk.it

import io.mockk.every
import io.mockk.mockk
import kotlin.test.Ignore
import kotlin.test.Test
import kotlin.test.assertEquals


class SealedClassTest {

@Test
@Ignore("Fails on JDK17+ https://github.com/mockk/mockk/issues/832")
fun serviceReturnsSealedClassImpl() {
val factory = mockk<Factory> {
every { create() } returns Leaf(1)
Expand All @@ -22,7 +20,6 @@ class SealedClassTest {
}

@Test
@Ignore("Fails on JDK17+ https://github.com/mockk/mockk/issues/832")
fun serviceAnswersSealedClassImpl() {
val factory = mockk<Factory> {
every { create() } answers { Leaf(1) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ package io.mockk.it
import io.mockk.every
import io.mockk.mockk
import kotlin.test.Test
import kotlin.test.Ignore
import kotlin.test.assertEquals


class SealedInterfaceTest {

@Test
@Ignore("Fails on JDK17+ https://github.com/mockk/mockk/issues/832")
fun serviceReturnsSealedClassImpl() {
val factory = mockk<Factory> {
every { create() } returns Leaf(1)
Expand All @@ -22,7 +20,6 @@ class SealedInterfaceTest {
}

@Test
@Ignore("Fails on JDK17+ https://github.com/mockk/mockk/issues/832")
fun serviceAnswersSealedClassImpl() {
val factory = mockk<Factory> {
every { create() } answers { Leaf(1) }
Expand Down

0 comments on commit 51dac76

Please sign in to comment.