You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please answer the following questions for yourself before submitting an issue.
I am running the latest version
I checked the documentation and found no answer
I checked to make sure that this issue has not already been filed (pretty sure but not 100%)
Expected Behavior
mockkConstructor should work on Android 13.
Current Behavior
Newly constructed objects are never spied on.
Failure Information (for bugs)
None visible; the objects simply do not run any every code, and simply function normally.
Steps to Reproduce
Define a class in your android package:
class MockCls {
fun add(a: Int, b: Int) = a + b
}
In an instrumented test, mock the class' constructor, then create a new instance and print it:
mockkConstructor(MockCls::class)
every { anyConstructed<MockCls>().add(1, 2) } returns 4
println(MockCls())
assertEquals(4, MockCls().add(1, 2)) // note new object is created
The mocked object will not actually be mocked/spied, and the assertion will fail.
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
MockK version: 1.13.10
OS: Android 13.0 Tiramisu
Kotlin version: 1.9.0
JDK version: Unknown, not sure how to check that on android
JUnit version: 4.13.2
Type of test: android instrumented test
Failure Logs
N/A
Stack trace
N/A
Minimal reproducible code (the gist of this issue)
// In main apppackageio.mockk.ghclassMockCls {
funadd(a:Int, b:Int) = a + b
}
// In test packagepackageio.mockk.ghimportio.mockk.everyimportio.mockk.mockkimportorg.apache.kafka.common.KafkaFutureimportkotlin.test.TestclassIssue69Test {
@Test
funtest() {
mockkConstructor(MockCls::class)
every { anyConstructed<MockCls>().add(1, 2) } returns 4
assertEquals(4, MockCls().add(1, 2)) // note new object is created. Test fails.
}
}
The text was updated successfully, but these errors were encountered:
Prerequisites
Please answer the following questions for yourself before submitting an issue.
Expected Behavior
mockkConstructor
should work on Android 13.Current Behavior
Newly constructed objects are never spied on.
Failure Information (for bugs)
None visible; the objects simply do not run any
every
code, and simply function normally.Steps to Reproduce
Define a class in your android package:
In an instrumented test, mock the class' constructor, then create a new instance and print it:
The mocked object will not actually be mocked/spied, and the assertion will fail.
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
Failure Logs
N/A
Stack trace
N/A
Minimal reproducible code (the gist of this issue)
The text was updated successfully, but these errors were encountered: