Clearly, Joseph did not know how to react to his brothers when they appear before him. He therefore tests them and it is only after Judah's emotional appeal when the cup is found in Benjamin's sack, that Joseph can be certain that the brothers have had a change of heart and are truly sorry for what they did to their brother and the suffering that their actions inflicted on their father. Forgiveness is easier when there is repentance. The story starts with Joseph's brothers saying they feared Joseph after the death of their father. The brothers sent a messenger to tell Joseph that their father commanded befor he died that Joseph forgive the trespasses of his brothers.
True forgiveness remembers no more the wrong done.
The entire remainder of the Old Testament attributes forgiveness to God only. As Mark Twain pointed out in The Innocent Abroad, it was much easier for Joseph in his position of wealth and power to forgive his brothers when they were struck low. Essau's forgiveness of Jacob, who robbed him of his birthright and blessing, was a much tougher act to do, especially when Essau encountered the betrayer's richly blessed procession of wives, children, and livestocks while he was still wandering in destitute.