Since running tests forever is not really practical for some cases. Is it possible to add a method to test for a specified duration. Something like that
extension Monkey {
func startTesting(forDuration duration: TimeInterval) {
let start = CFAbsoluteTimeGetCurrent() // start time
repeat {
actRandomly()
actRegularly()
} while ((CFAbsoluteTimeGetCurrent() - start) < duration)
}
}
Then we can call it that way:
// Run the monkey tests for 15 minutes
monkey.startTesting(forDuration: 15 * 60)
// or to fall back to forever testing
monkey.startTesting(forDuration: .infinity)
Since running tests forever is not really practical for some cases. Is it possible to add a method to test for a specified duration. Something like that
Then we can call it that way: