Keep in mind that the following answer is only my opinion. After teaching English for many years, I can tell you that the only way to virtually prevent cheating is to have the students take their tests (NO multiple choice) and write their essays BY HAND (or with access to Word only) within one class period while being strictly monitored. I say "virtually" because there is no way to prevent cheating 100%. There are always "wandering eyes." The smartest of the smart (the dumbest of the dumb?) will always find a way. Heck, it's how my prom date got into Harvard! My usual mantra is, "We can't control what other people do!"
The only way to prevent all students from cheating on tests or papers would be to have severe punishments for cheating and to have it be almost certain that anyone who actually cheated would be caught. Of course, this is not possible, but we can try.
To avoid having students cheat on tests, the teacher should move desks far enough apart to make it hard for students to see from one to another. It is also a good idea to have different versions of a test (with the same questions but in a different order) so that cheating will be more difficult. The teacher must patrol the classroom rather than just sitting at their desk.
On papers, it is much more difficult to prevent cheating. The best thing the teacher can do is to know what their students are capable of. It is not always easy to determine if someone has cheated, but if you know what their writing ability is, you can generally be suspicious of them if a paper seems beyond their capabilities. Also, you can read their papers carefully. If the quality and style of the writing varies widely, it is likely that some of it has been plagiarized. You can Google certain phrases that seem suspicious and see if they were taken directly from the internet.
This will not prevent all students from cheating, but it will make them less likely to cheat if they know that you are doing all of these things and if they know that they will be punished severely if they are caught.