And we know that all things work together for good to those who love God, to those who are the called according to His purpose Romans 8:28
Another reason that we can "count it all joy" in our times of testing is because God works those trials for our good and His glory. God uses the hardships that we face to conform us to the image of His Son (Romans 8:29), to draw us nearer to Him, and to strengthen our faith.
Thank you for your exhortation for us to practice patience.