mflint/SwiftMock

If two methods have same signature, it fails

RohitNegi opened this issue · 2 comments

If two methods have same signature but different method name, it is failing because it try to match with method mentioned top in the hierarchy.
Screenshot 2021-07-27 at 6 13 59 PM

for example

    func test_void_function() {
        //given
        viewModel = FroodViewModel(delegate: mockFrood)
        //expect
        mockFrood.expect { (f) in
            f.voidFunction(value: 11)
        }
        //when
        viewModel.checkVoidFunction(val: 11)
        //then
        verify()
    }
    
    func test_void_function1() {
        //given
        viewModel = FroodViewModel(delegate: mockFrood)
        //expect
        mockFrood.expect { (f) in
            f.voidFunction1(value: 11)
        }
        //when
        viewModel.checkVoidFunction(val: 11)
        //then
        verify()
    }

Can you post the code for your Mock object please?

Please also give more details about how "it fails"? What is the failure, and what did you expect to happen?

my bad, setting up of expectation was incorrect that's why it was failing. It should have been like viewModel.checkVoidFunction1(val: 11).
thanks for reply.