A person might ask: "If some calamity or difficulty afflicts me, how will I know if it's a test from Allaah Ta`aalaa, to bring me closer to Him, or if it is a Divine Punishment?"
The Hukamaa (Wise Men) have given a simple answer:
If after the difficulty befalls you, you become closer to Allaah, then it was a test (and you have passed). If after the difficulty befalls you, you move away from Allaah, then it was a Divine Punishment.
والله تعالى أعلم