Cryptic verification failed message in the IDE
See original GitHub issueMockK: 1.12.0 AssertJ Core: 3.20.2 JUnit Jupiter: 5.7.2 Kotlin: 1.6.10 Koin Test JUnit5: 3.1.5 Android Studio Chipmunk 2021.2.1 Patch 1
When I run one of my tests I get a very cryptic message in the Android Studio test result window:
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9yZy5qdW5pdC5wbGF0Zm9ybS5lbmdpbmUuc3VwcG9ydC5oaWVyYXJjaGljYWwuTm9kZVRlc3RUYXNrLmxhbWJkYSRleGVjdXRlUmVjdXJzaXZlbHkkOCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKE5vZGVUZXN0VGFzay5qYXZhOjEyNykgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9yZy5qdW5pdC5wbGF0Zm9ybS5lbmdpbmUuc3VwcG9ydC5oaWVyYXJjaGljYWwuVGhyb3dhYmxlQ29sbGVjdG9yLmV4ZWN1dGUgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKFRocm93YWJsZUNvbGxlY3Rvci5qYXZhOjczKSAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9yZy5qdW5pdC5wbGF0Zm9ybS5lbmdpbmUuc3VwcG9ydC5oaWVyYXJjaGljYWwuTm9kZVRlc3RUYXNrLmV4ZWN1dGVSZWN1cnNpdmVseSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKE5vZGVUZXN0VGFzay5qYXZhOjEyNikgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9yZy5qdW5pdC5wbGF0Zm9ybS5lbmdpbmUuc3VwcG9ydC5oaWVyYXJjaGljYWwuTm9kZVRlc3RUYXNrLmV4ZWN1dGUgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKE5vZGVUZXN0VGFzay5qYXZhOjg0KSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqYXZhLnV0aWwuQXJyYXlMaXN0LmZvckVhY2ggI
(…)
hbC53b3JrZXIuY2hpbGQuU3lzdGVtQXBwbGljYXRpb25DbGFzc0xvYWRlcldvcmtlci5jYWxsKFN5c3RlbUFwcGxpY2F0aW9uQ2xhc3NMb2FkZXJXb3JrZXIuamF2YToxMzMpCglhdCBvcmcuZ3JhZGxlLnByb2Nlc3MuaW50ZXJuYWwud29ya2VyLmNoaWxkLlN5c3RlbUFwcGxpY2F0aW9uQ2xhc3NMb2FkZXJXb3JrZXIuY2FsbChTeXN0ZW1BcHBsaWNhdGlvbkNsYXNzTG9hZGVyV29ya2VyLmphdmE6NzEpCglhdCB3b3JrZXIub3JnLmdyYWRsZS5wcm9jZXNzLmludGVybmFsLndvcmtlci5HcmFkbGVXb3JrZXJNYWluLnJ1bihHcmFkbGVXb3JrZXJNYWluLmphdmE6NjkpCglhdCB3b3JrZXIub3JnLmdyYWRsZS5wcm9jZXNzLmludGVybmFsLndvcmtlci5HcmFkbGVXb3JrZXJNYWluLm1haW4oR3JhZGxlV29ya2VyTWFpbi5qYXZhOjc0KQo=]]></stackTrace><ijLogEol/> <failureType>assertionFailed</failureType><ijLogEol/> </result><ijLogEol/> </test><ijLogEol/></event></ijLog>
TimeAutomationPresenterTest > Solar > enable save if sunset trigger after set new geolocation() FAILED java.lang.AssertionError at TimeAutomationPresenterTest.kt:654
1 test completed, 1 failed
> Task :myapp:automation:testDevDebugUnitTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':myapp:automation:testDevDebugUnitTest'.
> There were failing tests. See the report at: file:///Users/lukaszkalnik/projects/my-app-android/myapp/automation/build/reports/tests/testDevDebugUnitTest/index.html
The generated HTML test report at the above file:///
path, however, when viewed in a browser, is correct (shows the failing test and the exact failed verification):
java.lang.AssertionError: Verification failed: calls are not in verification order
Matchers:
+TimeAutomationView(#1).enableSave(eq(false)))
TimeAutomationView(#1).setCurrentLocation(null()))
TimeAutomationView(#1).setCurrentLocation(eq(Holzmarkt 1)))
+CommonConnectorApi(#6).getTimeAutomation(eq(automationDetailId), any()))
+TimeAutomationView(#1).enableSave(eq(true)))
+TimeAutomationView(#1).showWeekdays(eq([AutomationDay(selected=true, title=automation_sunday, value=sun), AutomationDay(selected=false, title=automation_monday, value=mon)])))
Calls:
1) +TimeAutomationView(#1).enableSave(false)
2) TimeAutomationView(#1).setTime(0, 0, Europe/Berlin)
3) TimeAutomationView(#1).showScenes([AutomationScene(selected=true, title=Außenbeleuchtung einschalten, value=scene_1234), AutomationScene(selected=false, title=Warmes Licht, value=scene_7890)])
4) TimeAutomationView(#1).showTriggers([AutomationTrigger(selected=false, title=automation_trigger_time, value=TIME), AutomationTrigger(selected=true, title=automation_trigger_sunrise, value=SUNRISE), AutomationTrigger(selected=false, title=automation_trigger_sunset, value=SUNSET)])
5) +TimeAutomationView(#1).enableSave(false)
6) TimeAutomationView(#1).setTrigger(SUNRISE)
7) +TimeAutomationView(#1).showWeekdays([AutomationDay(selected=true, title=automation_sunday, value=sun), AutomationDay(selected=false, title=automation_monday, value=mon)])
8) TimeAutomationView(#1).enableTestAutomation(true)
9) TimeAutomationView(#1).showGeolocationDetails(null)
10) +CommonConnectorApi(#6).getTimeAutomation(automationDetailId, continuation {})
11) +TimeAutomationView(#1).enableSave(true)
12) TimeAutomationView(#1).setTime(0, 0, Europe/Berlin)
13) TimeAutomationView(#1).showScenes([AutomationScene(selected=true, title=Außenbeleuchtung einschalten, value=scene_1234), AutomationScene(selected=false, title=Warmes Licht, value=scene_7890)])
14) TimeAutomationView(#1).showTriggers([AutomationTrigger(selected=false, title=automation_trigger_time, value=TIME), AutomationTrigger(selected=true, title=automation_trigger_sunrise, value=SUNRISE), AutomationTrigger(selected=false, title=automation_trigger_sunset, value=SUNSET)])
15) +TimeAutomationView(#1).enableSave(true)
16) TimeAutomationView(#1).setTrigger(SUNRISE)
17) +TimeAutomationView(#1).showWeekdays([AutomationDay(selected=true, title=automation_sunday, value=sun), AutomationDay(selected=false, title=automation_monday, value=mon)])
18) TimeAutomationView(#1).enableTestAutomation(true)
19) +TimeAutomationView(#1).enableSave(true)
20) TimeAutomationView(#1).setCurrentLocation(Holzmarkt 1)
Stack traces:
1) io.mockk.impl.InternalPlatform.captureStackTrace (InternalPlatform.kt:124)
io.mockk.impl.stub.MockKStub.handleInvocation (MockKStub.kt:250)
io.mockk.impl.instantiation.JvmMockFactoryHelper$mockHandler$1.invocation (JvmMockFactoryHelper.kt:23)
io.mockk.proxy.jvm.advice.Interceptor.call (Interceptor.kt:21)
io.mockk.proxy.jvm.advice.BaseAdvice.handle (BaseAdvice.kt:42)
io.mockk.proxy.jvm.advice.jvm.JvmMockKProxyInterceptor.interceptNoSuper
The failing test looks like this (dependencies of the presenter
are mocked with MockK and injected using KoinMockProvider
.
@JvmField
@RegisterExtension
val koinTestExtension = KoinTestExtension.create {
modules(koinMockModule)
}
@JvmField
@RegisterExtension
val koinMockProvider = MockProviderExtension.create { mockkClass(it) }
private val view = mockk<TimeAutomationView>(relaxUnitFun = true)
private lateinit var commonConnectorApi: CommonConnectorApi
private lateinit var systemDetailsRepository: SystemDetailsRepository
@BeforeEach
fun initMocks() {
commonConnectorApi = declareMock()
systemDetailsRepository = declareMock {
every { systemDetails } returns systemDetailsStateFlow
every { refreshGeolocation() } just Runs
}
}
@Test
fun `enable save if sunset trigger after set new geolocation`() = testScope.runTestAndCancel {
with(presenter.test()) {
attachView(view)
presenter.onGeolocationClicked()
detachView()
systemDetailsStateFlow.value = SystemDetailsState(
geolocation = DataState.DataLoaded(geolocation),
geolocationString = DataState.DataLoaded(address)
)
attachView(view)
}
coVerifyOrder {
view.enableSave(false)
view.setCurrentLocation(null)
view.setCurrentLocation(address)
commonConnectorApi.getTimeAutomation("automationDetailId")
view.enableSave(true)
view.showWeekdays(automationDays)
}
}
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6
Top GitHub Comments
Really looks like an IDE issue rather than an issue with mockk, closing this.
Created an issue for IntelliJ in JetBrains’ YouTrack: https://youtrack.jetbrains.com/issue/IDEA-297052/JUnit5-test-prints-a-cryptic-AssertionError-message-in-the-IDE