Unit Test in Django doesn’t running the test method inside the TestCase


If you got the problem like what I mention on the title, that’s mean you need to take a rest. Why? The big possibilty is sometimes we forgot to add “test” as prefix on our testCase method. For instance:

1
2
3
4
5
6
7
8
class InsuranceTestCase(TestCase):
    """Insurance unit-testing"""

    def setUp(self):
        pass

    def check_whether_user_valid(self):
        pass

When you running this unit-test, Django will give result 0 test has been executed. So, the correct way is :

1
2
3
4
5
6
7
8
class InsuranceTestCase(TestCase):
    """Insurance unit-testing"""

    def setUp(self):
        pass

    def test_check_whether_user_valid(self):
        pass

Simple! 🙂


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.