GithubHelp home page GithubHelp logo

Comments (3)

linfan avatar linfan commented on May 2, 2024

已复现,会在近期修复~
感谢反馈🌸

from testable-mock.

linfan avatar linfan commented on May 2, 2024

问题(1)在0.4.8版本已修复。

(2)的情况稍微特殊一点,需要代码编写的时候加一个类型转换处理。

直接这样写在编译时候会报同时匹配多个可用重载方法的错误:

Assertions.assertThat(demoPrivateAccess.privateFunc()).isEqualTo("member");

加一个和privateFunc()方法返回值匹配的类型转换,就可以正常编译通过。

Assertions.assertThat((String)demoPrivateAccess.privateFunc()).isEqualTo("member");

原因是TestableMock在转换私有方法或者字段访问后,返回的是模板类型,由编译器在编译时自动判断实际类型。但assertThat()方法有多种重载方法都能匹配到这个模板类,导致编译器无法正常选择要调用的重载方法,加上类型转换能为编译器明确指定一种重载调用。
或者是先赋值到变量,然后用assertThat,即转换成(1)这种情况来使用。

from testable-mock.

scxkd2016 avatar scxkd2016 commented on May 2, 2024

问题(1)在0.4.8版本已修复。

(2)的情况稍微特殊一点,需要代码编写的时候加一个类型转换处理。

直接这样写在编译时候会报同时匹配多个可用重载方法的错误:

Assertions.assertThat(demoPrivateAccess.privateFunc()).isEqualTo("member");

加一个和privateFunc()方法返回值匹配的类型转换,就可以正常编译通过。

Assertions.assertThat((String)demoPrivateAccess.privateFunc()).isEqualTo("member");

原因是TestableMock在转换私有方法或者字段访问后,返回的是模板类型,由编译器在编译时自动判断实际类型。但assertThat()方法有多种重载方法都能匹配到这个模板类,导致编译器无法正常选择要调用的重载方法,加上类型转换能为编译器明确指定一种重载调用。
或者是先赋值到变量,然后用assertThat,即转换成(1)这种情况来使用。

收到

from testable-mock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.