mirror of
https://github.com/alibaba/testable-mock.git
synced 2026-08-22 19:23:29 +08:00
fit for kotlin auto generated accessor method
This commit is contained in:
@@ -31,7 +31,7 @@ class DemoMockTest {
|
||||
}
|
||||
|
||||
@MockMethod
|
||||
private String staticFunc(DemoMock self) {
|
||||
private String staticFunc(DemoMock ignore) {
|
||||
return "_MOCK_TAIL";
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ class DemoMockTest {
|
||||
void should_able_to_mock_member_method() throws Exception {
|
||||
assertEquals("{ \"res\": \"mock_hello_MOCK_TAIL\"}", demoMock.outerFunc("hello"));
|
||||
verify("innerFunc").with("hello");
|
||||
verify("staticFunc").with();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -61,5 +61,9 @@ class DemoMock {
|
||||
private fun staticFunc(): String {
|
||||
return "_STATIC_TAIL"
|
||||
}
|
||||
|
||||
// fun callStaticFunc(): String {
|
||||
// return "CALL${staticFunc()}"
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ internal class DemoMockTest {
|
||||
private fun innerFunc(self: DemoMock, text: String) = "mock_$text"
|
||||
|
||||
@MockMethod
|
||||
private fun staticFunc(self: DemoMock): String {
|
||||
private fun staticFunc(ignore: DemoMock): String {
|
||||
return "_MOCK_TAIL";
|
||||
}
|
||||
|
||||
@@ -72,8 +72,15 @@ internal class DemoMockTest {
|
||||
fun should_able_to_mock_member_method() {
|
||||
assertEquals("{ \"res\": \"mock_hello_MOCK_TAIL\"}", demoMock.outerFunc("hello"))
|
||||
verify("innerFunc").with("hello")
|
||||
verify("staticFunc").with()
|
||||
}
|
||||
|
||||
// @Test
|
||||
// fun should_able_to_mock_method_in_companion_object() {
|
||||
// assertEquals("CALL_MOCK_TAIL", DemoMock.callStaticFunc())
|
||||
// verify("staticFunc").with()
|
||||
// }
|
||||
|
||||
@Test
|
||||
fun should_able_to_mock_common_method() {
|
||||
assertEquals("trim_string__sub_string__false", demoMock.commonFunc())
|
||||
|
||||
Reference in New Issue
Block a user