'unit test work flow

New to unit test. Try to make sure I understand it correctly.

1> I wrote a module "foo111.py", contains one function "add"

2> I want to test "add'. I create a script called "test_foo111.py"

3> in the test script, I create a "test_add", I call it from the main of the test script (pls see picture below)

4> When I click on "main" of the test_foo111.py, the script run in normal debug mode.

5> only when I click on the "test_add" function, the script run in testing mode.

I thought I'm able to call all the test from the main(imagine I will have more functions in foo111), so that I don't need to run all the test one by one???? I think I must mis-understood something here.. step 4 step 4

step 5 step 5



Solution 1:[1]

You need to use the unit test framework you need to import it like that:

import unittest

And your class signature should look like this:

class myTestClass (unittest.TestCase):
    def TestName(self):

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1