mercredi 19 septembre 2018

Mocking individual struct function

I'm a little confused with this case.

I have a struct. Let's say:

type User struct{}

then I have 3 functions for this struct

func (u User) MethodA() {}
func (u User) MethodB() {}
func (u User) MethodC() {}

inside methodA it will call function from MethodB

func (u User) MethodA() {
   .....
   u.MethodB()
   .....
}

How can I do unit test for this? If I mock the User then the unit test will be invalid because I have to mock methodA.

Aucun commentaire:

Enregistrer un commentaire