I want to setup unit tests for my lambdas that are written in Python. I am using aws-cdk to develop and deploy my lambdas. How do I propperly setup these unit tests? Which libraries do I use? How to put it in a packet structure? Maybe an example can clarify.
I was looking into the library 'unittest'. I set up a folder names 'test' and put a test file in there named: test_first.py. I could then execute all test files in this folder by using the command: python -m unittest discover ./test
test_first.py
import unittest
class FirstTest(unittest.TestCase):
def test_default(self):
self.assertEqual(10, (5+5))
if __name__ == '__main__':
unittest.main()
Is this the right way to do this? I now have the problem that I don't know how to import another python file and test its methods in this file. This would be the lambda I have written and test its methods. How do I do this?