You'll have to be more specific if you want a specific answer.
You can run a WHILE loop. Outside the loop, use the GET DATE/TIME IN SECONDS function to get the current time. Add 300 to it (5 minutes), and pass it into the loop.
Inside the loop, do your testing work.
Use another GET DATE/TIME IN SECONDS inside the loop, and compare the current time to the target stop time (the one computed outside the loop). If NOW >= TARGET TIME, then stop the loop.