-
Notifications
You must be signed in to change notification settings - Fork 0
1. Automated Test in Python
Automated Test
When most people say "unit tests", they really mean "automated tests" where the tests are run by the machine.
Making your tests work harder and smarter.. to make your life easier.
The Anatomy of Unit Test
A unit test covers a specific component in isolation. This "component" can be a function, a class, or some composition of them together. As I define it here, a unit test checks for a specific response to a particular input.

- use Python's built-in unittest framework
- any member function whose name begins with test in a class deriving from unittest.TestCase will be run
- assertions checked when unittest.main() is called

The key idea of a unit test - testing a component in isolation - extends in some non-obvious ways. Strictly speaking, an automated test is not a unit test if it does any of the following:
- Any operation over the network
- Read from or write to any data store
- Connect with any third-party service or API
- Touch the file system, except perhaps to load some initial test data or a fixture
In other words, unit test typically means:
- covers code that is limited to functionality / scope
- ideally, a single method with limited external calls
- for each method that contains business logic
Third Party Test Framework
The most common are:-
The Real Value of Unit Tests
If your automated tests are segmented in terms of unit tests, you probably have a build environment in which they can independently run. The point of the restrictions on unit tests is so they run very fast. Ideally, all unit tests run in less than one minute total on your development machine. Even better if it is under a dozen seconds. This allows you to run them early and often as you develop, quickly discovering if your changes break some other part of the system.
Credits:-