Junior — Middle
Have you tried conducting testing in your previous project or job?
sobes.tech AI
Answer from AI
Yes, I have conducted testing in my projects using various approaches. In Python, the unittest or pytest modules are often used for writing automated tests.
For example, a simple test of an addition function using unittest:
import unittest
def add(a, b):
return a + b
class TestAddFunction(unittest.TestCase):
def test_add_positive_numbers(self):
self.assertEqual(add(2, 3), 5)
def test_add_negative_numbers(self):
self.assertEqual(add(-1, -1), -2)
if __name__ == '__main__':
unittest.main()
Testing helps ensure that the code works correctly and facilitates early detection of errors during development.