Paying attention in class should be as easy as watching your favorite movie, especially if you take part in whatever it is your teacher is presenting - ask questions, answer questions, take notes, do whatever it takes to keep your mind on the topic being taught.
Preparing for the test at home may not be as easy as paying attention in class, but if you put forth as much effort as you do playing video games or reading your favorite books, it should be easy peasy lemon squeezy! Are you stuck on how to prepare? Completely understandable, especially if smart study habits haven't been the main topic of discussion at home or in school! It's actually much simpler than one might think, you may just have to try a few ways to find the best type of study habits for you and your brain. Some suggestions - make flash cards with the problem or description on one side and the answer on the other (for example: 16th President of the USA/Abraham Lincoln); read your notes from class over and over again; talk about the topic with another person; use practice games; do your homework; or design your own way to study.
The most difficult of the three comes into play here - entering the test with a positive attitude. On the surface this may seem like the easiest; however, your mind can be swayed easily by lack of sleep, poor breakfast, not feeling well, something someone said to you, and countless other ways. One way to overcome this and reset your mind so-to-speak, is to close your eyes and take a deep breath, redirecting your focus onto the task at hand. If you are still finding yourself in a rut, ask to be excused to the bathroom so you can splash some water on your face or get a drink of water. If the distraction is that you are not feeling well, and it is truly a bother (your stomach is in such pain or you feel as though you may return your breakfast) ask to visit the nurse/clinic. Be advised; however, sometimes the thought of a test can make our stomachs churn with nervousness, so try breathing, sucking on a peppermint, and focusing on all the preparation you did.
Above all, tests should not send your mind into a tizzy, relax, and do your best.