First you declare that you want to pass a test; only then may your opponent shout “Hex” before your die roll. As a result, you'll fail the test without having rolled the die, but you may move onto the space your goal token is on.