meta replacing same method in two different tests not working?

后端 未结 1 446
失恋的感觉
失恋的感觉 2021-01-28 03:24

Test controller is as follows

def justTest(){

    def res = paymentService.justTest()

    [status: res.status]

}

Test service method is as f

相关标签:
1条回答
  • 2021-01-28 03:50

    I would take a different approach:

    void test1(){
        controller.paymentService = new PaymentService() {
            def justTest() {['status': true]}
        }
    
        def res = controller.justTest()
        assertEquals(res.status, true)
    }
    

    Or if you were using Spock instead of JUnit:

    void test1() {
        controller.parymentService = Stub() {
             justTest() >> [status: true]
        }
        // ...  other code
    }
    
    0 讨论(0)
提交回复
热议问题