Understanding automated testing in Django
Automated testing is helpful for a number of reasons. Developers use it when refactoring old components that need to be modified. Test scripts are used to regression test older components to see whether they were affected negatively by any new additions. Django offers several test classes that are an extension of the standard Python library called unittest
. You can learn more about this package here: https://docs.python.org/3/library/unittest.html. The Django test classes are all found in the django.test
library. The most commonly used class is TestCase
.
The following list depicts all of the test classes that are available in the django.test
library:
- SimpleTestCase – this is the smallest test possible, extending the Python
unittest
library. This class will not interact with a database. - TransactionTestCase – this test extends the
SimpleTestCase
class and allows for database transactions. - TestCase – this...