// NOTE: This method is not being tested here, code that uses this object is. // In the real object, this method would do something useful, but since this // is a mocked object - we're just going to stub it out. DoSomething is a method on MyMockedObject that implements some interface // and just records the activity, and returns what the Mock object tells it to. */ // MyMockedObject is a mocked object that implements an interface // that describes an object that the code I am testing relies on. The mock package provides a mechanism for easily writing mock objects that can be used in place of real objects when writing test code.Īn example test function that tests a piece of code that relies on an external object testObj, can setup expectations (testify) and assert that they indeed happened: package yours The require package provides same global functions as the assert package, but instead of returning a boolean result they terminate current test. If you assert many times, use the below: package yoursĪssert.Equal(123, 123, "they should be equal")Īssert.NotEqual(123, 456, "they should not be equal")
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |