I created a simple model test case using TestCase class. I created an object using setUp function and test the count of the object using assertEqual inside another function.
The test ran successfully, but when I check the Django admin, there was no object that I just created, and also there was no table named django_test.
My test case:
class TestContact(TestCase):
def setUp(self):
self.contact = Contact.objects.create(
full_name = "John Van",
email = "[email protected]",
phone = 9845666777,
subject = "My query",
message = "test message"
)
def test_contact_count(self):
self.assertEqual(Contact.objects.count(),1)
Also, is setUp, a built in function or we can use any function name while creating the object inside it??