CST 438 - Week 2
In lab 1 on Junit you used a Mock. In your own words describe what a Mock is and why it is useful in unit testing.
In the testing we did in lab 1 we used a mock to test if our functions were returning the correct data. The purpose of the mock is to be able to test the code without relying on external dependencies. This is useful in unit testing because external dependencies can have numerous issues such as a server being down or a different value being returned for every API request. This makes it very difficult to test if the functions return the expected output. It allows the logic of the code to be tested against set expected outputs, locally, to ensure the code functions as expected.
Comments
Post a Comment