zalando / SwiftMonkey

A framework for doing randomised UI testing of iOS apps
MIT License
1.95k stars 174 forks source link

Tests with Duration #29

Closed mohamede1945 closed 7 years ago

mohamede1945 commented 7 years ago

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)
cakushin commented 7 years ago

What is the monkey click frequency?

wojciechczerski commented 7 years ago

Solved by #43 - closing the issue.