Unit test on the method using testify

Hi, I want to mock the emp.Create() call using testify. Can anyone help on this?

//CreateEmployee is for creating the emp in an application
func CreateEmployee() error {
	var emp Employee
	//read the data from the request
	err := //method call to pass &emp and get the data
	err = emp.Create()
	return err

}

In mock, emp Object and emp Object in this function is different. so, I’m unable to perform. Is there anyway that without altering the signature, can I perform the test

I don’t quite understand what you mean by this. Which mock are you talking about? And why and how is emp different?

I want to mock emp.Create() function to test CreateEmployee().

OK. How do you do this?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.