Test-and-set is a way of telling a computer to keep track of something. It works by telling the computer to test whatever is being tracked and then set it to a new value. For example, if a computer is keeping track of how many apples you have, the way it does that is by giving it a test-and-set: test how many apples you have and then set the number to the new amount, like if you get two more apples. This way the computer knows you have the new amount.