If Allah is all knowing and knows the future why does he test us? Isn’t testing only for what you don’t know?

Since we believe that God knows everything, then why should He test us?

The test which we are to undergo is not meant to add to the knowledge of God. Although God knows everything, it still is necessary that all men and women be put to test so that the true form of God's justice and mercy may emerge on the Day of Judge