Have you ever felt that you did worse on an exam when you spent more time preparing for it than you have on exams you studied a little bit for and then 'winged' it? According to an article on Psychology Today, your hunch might be correct. As the article suggests, if you think you will have trouble learning something, you may be making it likely that you actually will.
Generally, if you know the information you have studied well, and are confident that you can succeed, you will be much less likely to experience the more negative effects of test anxiety. So sometimes, preventing test anxiety from occurring can involve simple things like studying the material thoroughly in advance but only briefly on the day of the test; and by giving yourself an encouraging pep talk before the test—reminding yourself that you understand the material well and are confident you can succeed. If you find that you are thinking so much about everything that is riding on the results of this test that it is causing you anxiety or panic, you may want to reword what you are thinking to remind yourself that the world will go on and life will still be bearable even if you fail. If none of that helps you calm down, try using a trick suggested in the article and practicing your test-taking beforehand in a slightly stressful situation. For example, when you are completing practice tests or quizzes that don’t count for a grade, try using a timer (set with a challenging but reasonable time for you to complete the exercise) so that you feel a little stress while taking the practice quiz. Practicing the answering of questions while you are stressed will help you be less fazed by the stress when it does happen. If your course doesn't have practice quizzes, try studying by creating your own quiz questions. Then take your own quiz with a timer several times. You will not only be learning to take tests better under stress, you will also be using very effective study habits to do it!