Testing

What is a test?

A test is code outside your program that runs some of your program's code to check whether it correctly works.

How do you write a test?

To write a test, you import the code you want to test, set up sample data, run the code using that data. Then, you can make assetions about the results.

What is an assertion?

An assetion is a statement about what a condition or value should be. For example, you might asset that the value of the variable age is greater than 18. If the code acts as it should, the test suceeds, otherwise, it fails.

Why should you write tests for your code?

Each part of a program solves one aspect of a bigger problems your program tries to solve. You can write tests that prove each part of your code properly behaves.

How do tests help you add new features to a project?

A good set of tests helps you find bugs before your users find them. It also helps ensure that when you add new features to your projects, the code doesn't affect the behavior of existing features and your program is still working.