How to unit test? part 2 of 2
So with all unit test you will want to run a set up and tear down that will run before each test. This sets up the data you are using to test. You will want to also create a mock database as you are testing the code and not your integration with the database. Then for each unit test you will use the set up and implement a function of the code you are willing to test. Then you will use an assert to check that it is correct by comparing the data output with the correct answer and if it fails you will put out a specific error with the code. This helps you pin point exactly where it is failing. There are all different types of unit test so make sure you are using the correct asserts. To learn more about unit test you can go to the 2 links I provided and you can also go to Udemy and find a course on unit testing.