mercredi 3 août 2016

how to structure python api tests efficiently?

Could anyone help with best practices how to structure api tests? How about such structure?

Is it okay to use class that provides the general methods that need almost all the tests? The tests itself uses unittest class and inherit Common class.

   project
        __init__.py
        /resources
            __init__.py
            resource_name.csv # csv files for dictionaries
            /Scripts
                 __init__.py
                created_resources.py # scripts to create resources
        /tests
             __init__.py
             Common.py # general methods for api all api tests
             Constants.py # all constants for test 
             test_app.py

for each test planning use such constructor:

class TestSmthCool(unittest.TestCase, commons.Common): 
    def __init__(self, *a, **kw):
        super(TestSmthCool, self).__init__(*a, **kw)        
        Common.__init__(self, *a, **kw)

'll be glad for any tips thanks in advance

Aucun commentaire:

Enregistrer un commentaire