James is one of my favorite books in the Bible. Right at the beginning, the first chapter, verse 2 - troubles = joy. Huh? It's really not that simple...
when troubles of any kind come your way, consider it an opportunity for great joy. James 1:2 NLT
Trials produce testing, testing increases faith, faith builds endurance, endurance expands trust, trust leads to joy! A bit simplistic, but, it would take pages to fully dissect this chapter.
I found one 'formula' that is more on target than my 'interpretation':
TRIAL => TESTING => PERSEVERANCE => MATURITY