账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    mockito
    32
    0

    1.@injectmocks 只能注解在实现类上?

    2.我想请问下,我的一个实现类中调用了很多不同的服务,使用spring的注解注入的,如果我只想mock掉个别的服务,我该怎么做呢,现在使用@injectmocks 注解之后,实现类中的其他服务都为null,无法使用spring注入了。

    网上有的说,把实现类以injectmocks 和autowird一起注解,就可以,试了下,不行额。

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • Mockito is a popular Java testing framework that allows developers to write tests for mock objects, making it easy to test code that relies on external services or libraries. It provides a set of tools and annotations for creating mock objects, simulating interactions with those objects, and asserting that the results of those interactions match expected behavior. Mockito can be used for a variety of testing scenarios, such as testing REST APIs, testing database interactions, testing network requests, and more. It is known for its flexibility, ease of use, and powerful testing capabilities.

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部