GithubHelp home page GithubHelp logo

Comments (6)

linfan avatar linfan commented on May 2, 2024

问题已定位,是由于内部类型匹配的一个BUG导致的,方法参数类型为接口的时候会调用失败。预计在这周内发布下个版本修复哈~

from testable-mock.

linfan avatar linfan commented on May 2, 2024

已发布0.4.4版本,修复了这个问题,可以试试哈

from testable-mock.

telxs avatar telxs commented on May 2, 2024

已解决,有个实践问题想问下,就是我要模拟一个远程客户端调用超时或者各种错误类型,这个应该怎么写呢,我原本是想每一种情况定义一个mock方法,但是好像在同一个类是不行的,得拆分几个类?还有就是verify方法调用次数是根据方法名的,如果要mock方法有重名的话是累计计算的,怎么能够够精确一些

from testable-mock.

linfan avatar linfan commented on May 2, 2024

Mock方法里能接收到实际调用的参数,可以在方法里加一些根据入参进行判断的逻辑,返回不同类型的错误。
如果要Mock的方法有重名,为了在verify的时候做区分,可以把原方法名放到@MockMethod注解的targetMethod参数里,这样Mock方法本身就可以起不同名字区分开了。

from testable-mock.

telxs avatar telxs commented on May 2, 2024

这样第一个侵入性比较强,有些参数满足不了得添加一些控制参数,实际上这些参数只是测试用实际业务并没有。mock逻辑都写在一个方法里,复杂一点的话可能代码比较长,按照之前写的习惯,更倾向于一种测试用例一个方法,对于一个mock对象不同表现对象不同块,最后按测试场景按需组装不同的方法

from testable-mock.

linfan avatar linfan commented on May 2, 2024

是个普遍问题哈🤔

一种轻量的解法是在TestableMock里增加控制参数注入的机制,已创建issue-17,看看是否有更好的建议。

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.