The following applies to just about any electronics... it's also easier said than to do safely without risking the electronics in the process.
You would need to be able to monitor the temps of anything you stress test to avoid damage, sort of making just using a flight almost as good but risky when you are uncertain of their condition. Still, you want to get the electronics up to their higher operating temps that is recommended and then run them at that temp ( below the max temp... so I mean the higher operating temp which is lower than max ) and do it for an extended time. Because these also experience a lot of vibration, that also needs to be part of the testing.
The ESC should be easy to get to such temps just by having them under a constant load... I'm uncertain what would cause enough stress in a FC to do the same since you'd want to "work" all of the parts/functions of the FC.