MVP Mockito 单元测试

引用内容:
//测试库
// Dependencies for local unit tests
testImplementation deps.junit
testCompile deps.mockito.core
testImplementation deps.hamcrest
// Android Testing Support Library’s runner and rules
androidTestImplementation deps.atsl.runner
androidTestImplementation deps.atsl.rules

// Dependencies for Android unit tests
androidTestImplementation deps.junit
androidTestCompile deps.mockito.android
androidTestCompile deps.mockito.core

// Espresso UI Testing
androidTestImplementation deps.espresso.core
androidTestImplementation deps.espresso.contrib
androidTestImplementation deps.espresso.intents
androidTestImplementation deps.espresso.idling
implementation deps.espresso.idling_resource

// Resolve conflicts between main and test APK:
androidTestImplementation deps.support.annotations
androidTestImplementation deps.support.v4
androidTestImplementation deps.support.recyclerview
androidTestImplementation deps.support.app_compat
androidTestImplementation deps.support.design

下面是测试代码

    @Mock
    private lateinit var mView: MaterialManagermentClassifyContract.View

   @Before
    fun setUp() {
        MockitoAnnotations.initMocks(this)

   // The presenter wont't update the view unless it's active.
       `when`(mView.isActive()).thenReturn(true)
    }

注意Contract.View中不可以有fragment的引用,要不会报错,这个问题折腾了一天

结构
Mocking final types, enums and final methods
添加/mockito-extensions/org.mockito.plugins.MockMaker
并且内容为mock-maker-inline
方式 final 方法报错

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值