Junior — Middle
Is it possible to create automated tests without using special testing frameworks?
sobes.tech AI
Answer from AI
Yes, it is possible to create automated tests without using special testing frameworks. For example, you can write scripts that:
- Run functions or modules with specific input data.
- Check the results using conditional operators (
if) and comparison of expected and actual values. - Output reports or logs about the test results.
A simple example of a test without a framework:
def add(a, b):
return a + b
result = add(2, 3)
if result == 5:
print("Test passed")
else:
print("Test failed")
However, using testing frameworks (such as unittest, pytest) simplifies writing, organizing, and running tests, and also provides additional features.