To repeat your question, you are asking why a God who is Omniscient would test one or more of His creatures since He already knows the outcome.
This is merely a misunderstanding of the word "test." We perform scientific tests, for example, in an effort to find out more about them in a logical and systematic way whose point is accuracy. We test things to determine if they are genuine, for example, as in testing something that looks like a diamond to see if it is in fact diamond or merely glass or cubic zirconium. But this testing from a standpoint of not-knowing in order to find out, is not the sole reason for or type of testing.
An example among humans would be the man who discovered that ulcers can be caused by a bacteria, H pylori, which is treatable by antibiotics. After going through the type of testing mentioned above, he became convinced that he had proved his hypothesis with certainty. Presuming now for the sake of argument that he had been granted total knowledge on the subject of this matter, not merely been convinced by his own evidence (although that could also elucidate this point), we find him performing another test.
In reality, he actually did perform that test, by giving the H Pylori bacteria to himself, and thus prove to others such as the scientific and research community that his hypothesis was true. Had he not been fully convinced, he might have hesitated to expose himself to untreatable ulcers that before that had been considered a chronic incurable condition. But by testing himself, he proved his point (he got ulcers and then treated them with antibiotics successfully) without having to go through years of human subject research. So one can test to prove a fact not to oneself, but to prove to others. So one reason Allah tests us in this life is to prove to us, by which I mean all of us, not only the tested person but also those around him/her including a whole society (if applicable).
There is another reason as well. Allah gave us free will. Truth doesn't have to be fully comprehensible to us to be true. But because Allah is also supremely just, it is essential that our free will be tested; again, not for Allah, but for us. It would be unjust for a creature with free will to be given such a gift without also giving that creature (us in this case) the chance to exercise it in a meaningful way. And that "meaningful way" is giving us choices, consequential choices, which we must be allowed to make entirely using our own free will. Some of these choices involve how we learn: by making mistakes. That in itself makes us superior to the jinn as well as the angels, in that it is one thing to be guided without choice and another thing entirely, and with far greater risk and difficulty, to learn "on one's own".
Some of these choices are far more consequential: mainly, the ethical choices and choices regarding faith and attitude. For this reason we can achieve a greater reward (jannah or paradise) or punishment (hell), i.e., the consequences. At the same time, those important choices are considered "tests" because for us they involve risk. We do not know the outcome for certain. And Allah leaves the decision to us because we asked for (according to the Quran before being created) and got free will. The test is for us to see and understand how the consequences are just and since we are forewarned, to act in a way, for which way we are given guidance in Islam (the Quran and prophetic teachings), that will bring the best consequences.
So in fact it should be easier to see how Allah tests us for us to prove ourselves and to also see the outcome of others around us, and as a means for us to exercise our free will and make choices for which we must ultimately take responsibility — although we are given guidance and mercy from Allah to help us in this.