There are several possible ways. They can use monitoring software which requires you have your camera and microphone on for tests so that they can see if you are looking at notes or asking someone else for answer, and can see if you are opening other tabs to google (some even track eye movement to make sure your eyes don’t go elsewhere). They can use sites like Turnitin to check for plagiarism on essays and papers. In some cases, you are simply on the honor system and they don’t check on you, but trust you to be honest.