Junior — Middle
Have you created automated tests for your code?
sobes.tech AI
Answer from AI
Yes, I have created automated tests for my code. Automation testing helps quickly verify the correctness of functions and modules after changes.
For example, in Python, the unittest or pytest modules are often used for writing tests.
Here's a simple test example using unittest:
import unittest
def add(a, b):
return a + b
class TestAddFunction(unittest.TestCase):
def test_add_positive(self):
self.assertEqual(add(2, 3), 5)
def test_add_negative(self):
self.assertEqual(add(-1, -1), -2)
if __name__ == '__main__':
unittest.main()
Automated tests help identify errors early and ensure code stability as the project develops.