A fasting blood sugar test measures your blood sugar level after you've fasted for at least eight hours. This test is used to diagnose diabetes and pre-diabetes. In contrast, a random blood sugar test measures your blood sugar level at any time, regardless of when you last ate. This test is often used to diagnose diabetes during routine check-ups or if you're experiencing symptoms of high blood sugar.