Sobes.tech
Middle+

Tell me about garbage collector methods.

sobes.tech AI

Answer from AI

A test should fail when the functionality being tested does not meet expectations. This means the test has detected a bug or incorrect behavior.

For example, if a function should return the sum of two numbers but returns a different value, the test should fail.

In Python with unittest or pytest, this happens automatically if an assert fails:

def test_sum():
    result = sum([1, 2, 3])
    assert result == 6  # if result != 6, the test will fail

Failing a test manually can be done with exceptions or assert when conditions are not met. This helps identify and fix problems early in development.