0

Project structure:

project

  some_api
    __init__.py
    api1.py
    api2.py

  some-folder
    some-helper-module.py

lib
  some-libs

docs
  some-docs

Dockerfile

README.md

What should be the position for various tests

  • unit tests
  • function tests for the API
  • performance tests using API like Locust

Possible Solution

In the parallel of project, I can have something like

test
  unit_tests
    test1.py
    test2.py

  functional_tests
    f_test1.py
    f_test2.py

  perf_tests
   locust-files
     load_test1.py
     load_test2.py
   test-data
     something.csv
Dev
  • 13,492
  • 19
  • 81
  • 174

2 Answers2

1

Generally, this structure is usually followed, Hope it helps. All types of test should be inside the test module with seperate submodule. For more details you can visit here

├── app_name
        │
        ├── app_name
        │   ├── __init__.py
        │   ├── folder_name
        │   └── etc...
        ├── tests
        │   ├── unit
        │   └── integration
        ├── README.md
        ├── setup.py
        └── requirements.txt
GOVIND DIXIT
  • 1,748
  • 10
  • 27
1

In our team we used to put the unit tests alongside the python files they refer to, and the integration and performance tests outside the project as they will test it almost as blackbox :

project

  some_api
    __init__.py
    api1.py
    api1_unit_testing.py
    api2.py
    api2_unit_testing.py

  some-folder
    some-helper-module.py

lib
  some-libs

docs
  some-docs

tests
  profiling_performance.py
  integration_testing.py

Dockerfile

README.md
Dev
  • 13,492
  • 19
  • 81
  • 174
Dali
  • 344
  • 1
  • 10
  • I think this will make running tests difficult. It will be easy to run if they are in one place separately. I guess? – GOVIND DIXIT Jul 12 '19 at 11:15
  • I agree for the performance and functional tests, but unit tests are very dependent of the DUT, so we like to keep them close, when they evolve it's easy to update them (see thread https://stackoverflow.com/questions/2843795/where-do-you-put-your-unit-test). – Dali Jul 12 '19 at 11:18
  • Moreover unit tests frameworks can find the unit tests recursively so there is not more complexity to run them – Dali Jul 12 '19 at 11:19
  • @Abel I modified your answer as I made a minor change in the question. I hope you don't mind. – Dev Jul 12 '19 at 11:26