ELI5: Explain Like I'm 5

Test assertion

When we test something, we want to make sure it does what it's supposed to do. A test assertion is like a grown-up promise that we make about what we expect will happen when we test something. We use test assertions to check that our code is doing what we think it should be doing.

For example, if we are testing a calculator app and we expect it to add numbers correctly, we would create an assertion that says "When I add 2 and 2, I expect the answer to be 4". We can then run our test and see if the app gives us the expected answer of 4.

In short, an assertion is a statement we make about what we expect to happen when we test something, and we use it to check that our code is working correctly.
Related topics others have asked about: