-
-
Notifications
You must be signed in to change notification settings - Fork 350
Home
Antonio Martinović edited this page Mar 5, 2021
·
20 revisions
Fresh development setup
- Clone repo by executing
git clone git@github.com:mockk/mockk.git
- [Optional] Install Android SDK and Android NDK
- Build project by executing
./gradlew
build or use IntelliJ IDEA integrated tools to build and test
To run all tests, execute:
./gradlew test
or to run a specific test:
./gradlew :mock-jvm:test --tests "io.mockk.gh*"
This will run all tests of project mock-jvm that are in package io.mockk.gh For more rules you can reference Gradle docs
With few known approaches troubleshooting may be a lot easier.
To see results of class transformation(and untransformation) add following system variable:
java -Dio.mockk.classdump.path=some-directory ...
After running your code transformed class files should appear in some-directory
.
Put logback-test.xml
in your resources(test-resources
) folder:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<statusListener class="ch.qos.logback.core.status.NopStatusListener"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<root level="trace">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
((MockKGateway.implementation() as JvmMockKGateway).stubRepo.stubs as JvmWeakConcurrentMap).map
This particular gives access to all stubs, but you may access different other objects from JvmMockKGateway
(((MockKGateway.implementation() as JvmMockKGateway).mockFactory as JvmMockFactory).proxyMaker as io.mockk.proxy.jvm.ProxyMaker)
Class.forName("io.mockk.proxy.jvm.dispatcher.JvmMockKDispatcher").getDeclaredFields()[0].apply{ isAccessible = true }.get(Class.forName("io.mockk.proxy.jvm.dispatcher.JvmMockKDispatcher"))
(Class.forName("io.mockk.proxy.jvm.advice.SelfCallEliminator").declaredFields[0].apply { isAccessible = true }.get(Class.forName("io.mockk.proxy.jvm.advice.SelfCallEliminator")) as ThreadLocal<*>).get()
- Basics
- DSL, Gateway & Agent layers 14:13
- Mock creation - basic flow 21:14
- Mock creation - inlining 29:32
- Mock creation: subclass instrumentation
- Mock creation: instantiation
- Mock creation: cancellation
- (MockK/SpyK creation)
- mockkObject, mockkStatic, mockkConstructor
- Mocking by annotation
- Tests(prinicples & layout)
- Code transformation
- ByteBuddy inlining
- ByteBuddy subclassing
- DEX Maker inlining
- DEX Maker subclassing
- Call recording
- Recording states
- Signatures
- Autohinting
- Chain detection
- Verification
- verify
- verifyAll
- verifyOrder
- verifySequence
- verify(timeout=X)
-
io.mockk:mockk (mockk/jvm)
JVM MockK implementation-
io.mockk:mockk-dsl-jvm (dsk/jvm)
JVM support functions for DSL -
io.mockk:mockk-common (mockk/common)
common MockK implementation-
io.mockk:mockk-dsl (dsl/common)
common MockK DSL interface
-
io.mockk:mockk-dsl (dsl/common)
-
io.mockk:mockk-agent-jvm (agennt/jvm)
call interception for JVM-
io.mockk:mockk-agent-common (agent/common)
common call interception code(Android and JVM) -
io.mockk:mockk-agent-api (agent/common)
common API(Android and JVM) for call interception -
org.objenesis:objenesis (2.6)
library to instantiate objects -
net.bytebuddy:byte-buddy (1.9.3)
library to modify byte-code -
net.bytebuddy:byte-buddy-agent (1.9.3)
library to modify byte-code on flight
-
io.mockk:mockk-agent-common (agent/common)
-
io.mockk:mockk-dsl-jvm (dsk/jvm)
-
io.mockk:mockk-android (mockk/android)
Android implementation is based on JVM(with JVM agent exclusion)-
io.mockk:mockk (mockk/jvm)
JVM MockK implementation-
io.mockk:mockk-common (mockk/common)
common MockK implementation-
io.mockk:mockk-dsl (dsl/common)
common MockK DSL interface
-
io.mockk:mockk-dsl (dsl/common)
-
io.mockk:mockk-dsl-jvm (dsl/jvm)
JVM support functions for DSL
-
io.mockk:mockk-common (mockk/common)
-
io.mockk:mockk-agent-android (agent/android)
call interception for Android (drop-in replacement for mockk-agent-jvm)-
io.mockk:mockk-agent-common (agent/common)
common call interception code(Android and JVM) -
io.mockk:mockk-agent-api (agent/common)
common API(Android and JVM) for call interception -
org.objenesis:objenesis (2.6)
library to instantiate objects -
com.linkedin.dexmaker:dexmaker (2.12.1)
library to modify dex-code
-
io.mockk:mockk-agent-common (agent/common)
-
io.mockk:mockk (mockk/jvm)