An attempt to rid the world of “assert True = True” forever. A Harsh Truth If you are going to write meaningless unit tests that are more likely to mask errors than expose them, you are better off skipping the exercise altogether.
If you are going to write meaningless unit tests that are more likely to mask errors than expose them, you are better off skipping the exercise altogether.
There, I said it.
Your time is precious and could be spent on better things than achieving a hollow coverage percentage.
Effective testing of code has long been a challenging problem in programming, and newer tools like AWS Lambda seem to bring out the worst in developers when it comes to writing tests.
I think the main reason for this is that it’s more difficult (or at least less intuitive) to mirror the Lambda production environment locally. And as a result, some developers choose to abstain from any local testing entirely.
I know because I’ve done it myself, even for projects in production. Instead, testing was done integration-style only after code was already deployed to the cloud.
This is extremely manual and wastes time in the long run.
Another approach I’ve seen results in tests that look something like this:
This is the unmistakeable sign of an engineering team with a test coverage requirement but a lack of accountability. And no explanation is needed that the above is a no-no.
So, how do we go about transforming the sad
test_lambda_function.py file above into something meaningful?
Before we can dive right into testing our Lambda code, there are a couple hurdles in the way. We’ll cover each of these individually and determine how to best handle them. Once dealt with, we are then free to test Lambdas to our heart’s content!
Note: I’ll be including small snippets of code throughout the article for clarity. But at the end there will be a full working code example to reference.
Python Programming & Data Handling
In the programming world, Data types play an important role. Each Variable is stored in different data types and responsible for various functions. Python had two different objects, and They are mutable and immutable objects.
Step-by-Step Tutorial: Scheduling your Python Script with AWS Lambda
🔵 Intellipaat Data Science with Python course: https://intellipaat.com/python-for-data-science-training/In this Data Science With Python Training video, you...
Understand how data changes in a fast growing company makes working with data challenging. In the last article, we looked at how users view data and the challenges they face while using data.