Randomly 'BeforeClass' event fired before 'BeforeDeploy' event

Hi,
Randomly ‘BeforeClass’ event fired before ‘BeforeDeploy’ event.
How do we can fix this?