Nicholas-C-Brown / COSC419F-Project

:)
1 stars 0 forks source link

Python Testing Library #3

Open ross-morrison opened 2 years ago

ross-morrison commented 2 years ago
Nicholas-C-Brown commented 2 years ago

Unit testing

For basic unit tests we can just use the built in unittest library.

Some important information when writing unit tests:

  1. Tests should be created in the tests directory.

  2. Every test should append the src directory to the sys.path.

    import sys
    import os.path
    sys.path.append(os.path.join(sys.path[0], '../src'))
  3. To create a test class, inherit from the unittest.TestCase class

    class TestExampleClass(unittest.TestCase):
  4. To ensure tests can be run by simple running the test file add the following

    if __name__ == '__main__':
    unittest.main()

GUI Tests

More research should be done with regard to writing tests for GUI code: https://towardsdatascience.com/automate-ui-testing-with-pyautogui-in-python-4a3762121973