Sobes.tech
Junior — Middle

What types of tests do you use to verify code during development?

sobes.tech AI

Answer from AI

To verify code during development, several types of tests are usually used:

  • Unit tests — check individual functions or methods for correctness in isolation.
  • Integration tests — verify interaction between components or modules.
  • Functional tests — ensure the system performs the specified functions.
  • Regression tests — guarantee that new changes haven't broken existing functionality.

In Python, the unittest or pytest modules are often used for unit testing.

Here's an example of a simple unit test using pytest:

# file test_example.py

def add(a, b):
    return a + b


def test_add():
    assert add(2, 3) == 5
    assert add(-1, 1) == 0