Retry a test when test fails

Hello,

Is there a way to set a number of retry times that when a test fails it will retry that number of times? Only when a test fails.

Thanks