Giter Club home page Giter Club logo

swiftmonkey's Introduction

SwiftMonkey

This project is a framework for generating randomised user input in iOS apps. This kind of monkey testing is useful for stress-testing apps and finding rare crashes.

It also contains a related framework called SwiftMonkeyPaws, which provides visualisation of the generated events. This greatly increases the usefulness of your randomised testing, as you can see what touches caused any crash you may encounter.

Why Use SwiftMonkey?

  • When testing your UI, it's very easy to think about how to test how things should work, but do you struggle to figure out what kind of thing might not work?
  • Ever showed your app to someone who proceeded to bang away at the screen and immediately crashed it by doing something you had never thought of?
  • Do you want to feel a bit more confident about your app's stability?
  • Do you have rare crashes that you just can't reproduce?
  • Do you have memory leaks that take a long time to manifest themselves, and require lots of UI actions?

Randomised testing will help you with all of these!

SwiftMonkey is inspired by and has similar goals to UI AutoMonkey, but is integrated into the Xcode UI testing framework, providing better opportunities to debug.

Also, it is fun to look at:

Quick Start

To see for yourself how this framework works, just grab the code and open SwiftMonkeyExample/SwiftMonkeyExample.xcodeproj. Then press Cmd-U to run the UI test.

Installation

As a high-level overview, add SwiftMonkey.framework to your UI test target. Then add a test that creates a Monkey object and uses it to generate events.

Optionally, you also add the SwiftMonkeyPaws.framework to your main app, and create a MonkeyPaws object to enable visualisation. You probably only want to do this for debug builds, or when a specific command line flag is used.

Requirements

SwiftMonkey uses Swift 4.0. It has no dependencies other than iOS itself (8.0 and up should work). SwiftMonkeyPaws doesn't have any dependencies, either; you can even use on its own, without SwiftMonkey.

CocoaPods

You can install the frameworks using CocoaPods. Assuming that you've named your main app and test targets "App" and "Tests", you can use something like this in your Podfile:

target 'App' do
    pod 'SwiftMonkeyPaws', '~> 2.1.0'
end

target 'Tests' do
    pod 'SwiftMonkey', '~> 2.1.0'
end

Manual Installation

Copy the SwiftMonkey and SwiftMonkeyPaws folders into your project. Next, drag the xcodeproj files into your project.

Then, for SwiftMonkey, add SwiftMonkey.framework as a dependency for your test target, and add a Copy Files build phase to copy it into Frameworks.

For SwiftMonkeyPaws, adding SwiftMonkeyPaws.framework to the Embedded Binaries section of your app target is enough.

(You can also just directly link the Swift files, if you do not want to use frameworks.)

Swift Package Manager

As of this writing, the Swift Package Manager doesn't support iOS projects. SPM package files have experimentally been created, but obviously don't really work yet.

Usage

SwiftMonkey

To do monkey testing, import SwiftMonkey, then create a new test case that uses the Monkey object to configure and run the input event generation. Here is a simple example:

func testMonkey() {
        let application = XCUIApplication()

        // Initialise the monkey tester with the current device
        // frame. Giving an explicit seed will make it generate
        // the same sequence of events on each run, and leaving it
        // out will generate a new sequence on each run.
        let monkey = Monkey(frame: application.frame)
        //let monkey = Monkey(seed: 123, frame: application.frame)

        // Add actions for the monkey to perform. We just use a
        // default set of actions for this, which is usually enough.
        // Use either one of these but maybe not both.

        // XCTest private actions seem to work better at the moment.
        // before Xcode 10.1, you can use
        // monkey.addDefaultXCTestPrivateActions()

        // after Xcode 10.1 We can only use public API
        monkey.addDefaultXCTestPublicActions()

        // UIAutomation actions seem to work only on the simulator.
        //monkey.addDefaultUIAutomationActions()

        // Occasionally, use the regular XCTest functionality
        // to check if an alert is shown, and click a random
        // button on it.
        monkey.addXCTestTapAlertAction(interval: 100, application: application)

        // Run the monkey test indefinitely.
        monkey.monkeyAround()
}

The Monkey object allows you not only to add the built-in event generators, but also any block of your own to be executed either randomly or at set intervals. In these blocks you can do whatever you want, including (but not only) generate more input events.

Documentation for this is limited at the moment, so please refer to Monkey.swift and its extensions for examples of how to use the more advanced functionality if you need it.

SwiftMonkeyPaws

The simplest way to enable the visualisation in your app is to first import SwiftMonkeyPaws, then do the following somewhere early on in your program execution:

var paws: MonkeyPaws?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    if CommandLine.arguments.contains("--MonkeyPaws") {
        paws = MonkeyPaws(view: window!)
    }
    return true
}

(This example uses application(_, didFinishLaunchingWithOptions), but any time after you have a UIWindow will do. It also only instatiates the visualisation if a certain command line flag is passed, so that it can be enabled only for test runs.)

Using command line flags, If you want to enable MonkeyPaws on your test case file you can add the following on yout testMonkey function:

  let application = XCUIApplication()
  application.launchArguments = ["--MonkeyPaws"]

This call will swizzle some methods in UIApplication to capture UIEvents. If you would rather not do this, or if you already have a source of UIEvents, you can pass the following option to init to disable swizzling:

paws = MonkeyPaws(view: window!, tapUIApplication: false)

Then you can pass in events with the following call:

paws?.append(event: event) // event is UIEvent

Contributing

Feel free to file issues and send pull requests for this project! It is very new and not overly organised yet, so be bold and go ahead. We will sort out the details as we go along.

Code style is currently just four-space identation and regular Apple Swift formatting.

Also, we have adopted the Contributor Covenant as the code of conduct for this project:

http://contributor-covenant.org/version/1/4/

Thanks to

  • The Zalando Open Source Guild for helping get this project off the ground.
  • João Nunes for help with documentation.
  • Jakub Mucha for bugfixing.

TODO

SwiftMonkey

  • Write more documentation.
  • Add more input event actions.
  • Add randomised testing using public XCTest APIs instead of private ones.
    • Find clickable view and click them directly instead of clicking random locations, to compensate for the slow event generation.
  • Fix swipe actions to avoid pulling out the top and bottom panels. (This can cause the monkey to escape from your app, which can be problematic!)
  • Generally, find a quick way to see if the monkey manages to leave the application.
  • Find out how to do device rotations using XCTest private API.
  • Find out why UIAutomation actions do not work on device, but only on the simulator.
  • Investigate other methods of generating input events that do not rely on private APIs.
  • Once Swift Package Manager has iOS support, update project to support it properly.

SwiftMonkeyPaws

  • Add more customisability for the visualisation.

SwiftMonkeyExample

  • Add more UI elements, views and controls to make the example look more interesting.
  • Maybe add some actual crashes that the monkey testing can find?

Contact

This software was originally written by Dag Ågren ([email protected]) for Zalando SE. This email address serves as the main contact address for this project.

Bug reports and feature requests are more likely to be addressed if posted as issues here on GitHub.

License

The MIT License (MIT) Copyright © 2016 Zalando SE, https://tech.zalando.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

swiftmonkey's People

Contributors

a455455b avatar applebaumian avatar dagagren avatar dmitrybespalov avatar dwaynecoussement avatar ilya2606 avatar insidegui avatar jinaiyuanbaojie avatar johennes avatar lfarah avatar nathanmrtns avatar perploug avatar wcrestfield avatar wojciechczerski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swiftmonkey's Issues

in xcode8, run monkeytest in real device

I am the SwiftMonkey tool user, this tool is amazing~I like it very much

But I want to run monkeytest in real device by xcode8, there is some solution for it?

2.0 fails to run for me; error in addXCTestTapAlertAction

Hi team

Congrats on getting 2.0 released, I'm excited to start using it, to remove a few custom hacks for activating the app to the foreground.

I tried to use 2.0 today and my tests fail to build when running it, after a 'pod repo update' + 'pod install'.

XCode logs a problem with addXCTestTapAlertAction's line:
let index = self!.r.randomInt(lessThan: buttons.count)
It suggests a fix like this:
let index = self!.r.randomInt(lessThan: Int(buttons.count))

Have I done something wrong, or is this legit?

Thanks

Daniel

Create Objective-C version of MonkeyPaws?

It might be worth creating an Objective-C version of MonkeyPaws, so that it can be more easily included in Objective-C only projects.

The test side can still use Swift without forcing the rest of the app to use it, and doesn't really need an Objective-C version, but the embedded visualisation could benefit.

If this is something you would like, please comment.

test failed when using xcode10 on a real device

I have downloaded the newest code from github today. When I test 'SwiftMonkeyexampleTests', I run into this:
image
However, I can run it on a simulator successfully. But when I run it on a real device, it fails.
How can I solve this problem? thanks.

Not supporting iOS8, as the README states?

I am trying to install SwiftMonkey using CocoaPods. My podfile specifies platform :ios, '8.0', but when I try to update it says the following:

[!] Unable to satisfy the following requirements:

  • SwiftMonkey (= 1.0) required by Podfile

Specs satisfying the SwiftMonkey (= 1.0) dependency were found, but they required a higher minimum deployment target.

The README specifically states: "It has no dependencies other than iOS itself (8.0 and up should work). SwiftMonkeyPaws doesn't have any dependencies, either; you can even use on its own, without SwiftMonkey."

Am I doing something wrong?

Tests with Duration

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)

Test in Specified app

Dear,
This is a magical tool, but I find that the monkey often test outside of the app, how to make sure the monkey is running in the app which I specified.

Look forward to your reply

                                                                                                                       Your Dear UserA

Monkey never stops if app crashes when testing with xcodebuild

I think SwiftMonkey is very powerful way to find crashes in an app 👍. Ideally I'd like to be able to run it from CLI. That would make it possible to create scripts that run SwiftMonkey non-stop, gather crash reports, screenshots etc.

However, currently if a test is being launched via xcodebuild test SwiftMonkey continues its frenzy even after the app has crashed (after some time, it usually crashes some system apps too 😀). xcodebuild also continues running after the app has crashed.

However if I create UI Test that "manually" executes the same button press that results in a crash, then xcodebuild reports failed test and stops.

The reason why Monkey keeps running is probably related to the fact that XCUIApplication().state returns .runningForeground even after the app has crashed (I checked by adding a line in func monkeyAround()). It seems that somehow Monkey is keeping it alive?

I'm experiencing this behaviour on Xcode 10, didn't try on Xcode 9 yet.

Can not run on real device

when I try to run test on real device, I got the following error:

Library not loaded: @rpath/SwiftMonkey.framework/SwiftMonkey

I can run it on simulator

Fail when start commandLine with DragAction

We have a problem when we launch MonkeyTest from command line (it works with Xcode but fail with xcodebuild)

we have this logs to help you :
t = 8.22s Tear Down
11:15:46.041 xcodebuild[32562:183033] _XCT_testCaseDidFailForTestClass:TestsUI.MonkeyTest method:testMonkey withMessage:failed: caught "NSInvalidArgumentException", "*** -[NSXPCEncoder _checkObject:]: This coder only encodes objects that adopt NSSecureCoding (object is of class 'NSMallocBlock')."

19 XCTest 0x0020341b -[XCEventGenerator pressAtPoint:forDuration:liftAtPoint:velocity:orientation:name:handler:] + 560
20 SwiftMonkey 0x0eb6cdf5 TFFC11SwiftMonkey6Monkey19addXCTestDragActionFT6weightSd_T_U_FT_T + 1157
21 SwiftMonkey 0x0eb63e89 TTRXFo___XFo_iT__iT_ + 25
22 SwiftMonkey 0x0eb63f4f TPA__TTRXFo___XFo_iT__iT_ + 95
23 SwiftMonkey 0x0eb63715 TTRXFo_iT__iT__XFo__ + 21
24 SwiftMonkey 0x0eb637fd TPA__TTRXFo_iT__iT__XFo__ + 61
25 SwiftMonkey 0x0eb63570 TFC11SwiftMonkey6Monkey11actRandomlyfT_T + 640
26 SwiftMonkey 0x0eb632df TFC11SwiftMonkey6Monkey12monkeyAroundfT_T + 31

When i remove addXCTestDragAction from addDefaultXCTestPrivateActions() it works

How to set throttle

Like Android's monkey test, I'd like to adjust the delay between each random events.
Is there any way to adjust the delay?

Linker command failed with exit code(use -v to see invocation)

When i run test case with real device, it shows build failed. Simulator can build and run monkey test
normally. The error message is :
Apple Mach-O Linker (Id) Error
Linker command failed with exit code(use -v to see invocation)

Please help me, thanks

How to run test

I am new to iOS.
I turned on iOS simulator and xcode.
When I tried 'Cmd+U' on the example, Xcode says that Build Succeeded.

What I expected is running monkey test. Could you tell me what am I missing?

image

SwiftMonkey cannot works on xCode 8.3

SwiftMonkeyExample build success, but run test shows build failed. I upgrade Xcode from 7.3 to 8.3. I Before it can works. So anybody know why?

Other build failed have not error detail.

[Memory leaks] Memory keeps increasing for a running monkey

From Xcode's Debug Navigator, I notice that memory usage grows from 40MB to 80MB for an hour monkey running. I believe it will keep increasing as the monkey goes on. Thus the UITest will fail at the end because of OOM (maybe the tested app will OOM too).

Test launch failing

Hi,
I am facing below error while running tests.
SwiftMonkeyExampleUITests-Runner.app (74021) encountered an error (Timed out waiting for AX loaded notification)

Tests run on setup:
Xcode Version 10.0 (10A255)
iOS Deployment target: iOS 11.0
Target simulator: iPhone 8 plus

Please help.

Cannot build SwiftMonkey from pods

Cannot call value of non-function type 'XCUIElement'

public func addXCTestTapAlertAction(interval: Int, application: XCUIApplication) {
    addAction(interval: interval) { [weak self] in
        // The test for alerts on screen and dismiss them if there are any.
        for i in 0 ..< application.alerts.count {
            let alert = application.alerts.element(boundBy: i)
            let buttons = alert.descendants(matching: .button)
            XCTAssertNotEqual(buttons.count, 0, "No buttons in alert")
            let index = UInt(self!.r.randomUInt32() % UInt32(buttons.count))
            let button = buttons.element(boundBy: index)
            button.tap()
        }
    }
}

let button = buttons.element(boundBy: index)

OC项目可以用吗

OC项目可以用吗?怎么用?望作者指点一二。如果可以的话,望作者能给出demo

Add to CocoaPods repo

SwiftMonkey and SwiftMonkeyPaws should be properly added to CocoaPods. I have no idea how yet, so if anyone wants to do it quickly, please go ahead!

Integrate linter and code formatter in the build process

To ensure code format consistency we could use SwiftFormat. We can integrate it as a build phase that triggers a warning or an error if swiftformat command was not found. If we choose the error approach we should clearly describe in README that in order to contribute to the project you should first make sure you have the swiftformat installed.

In addition we could use SwiftLint to ensure a consistent code style. The integration options are the same as for the SwiftFormat.

assertion failure

Assertion Failure: :0: Failure getting snapshot Error Domain=XCTestManagerErrorDomain Code=9 "Error -25204 getting snapshot for element <AXUIElement 0x1004357f0> {pid=6595}" UserInfo={NSLocalizedDescription=Error -25204 getting snapshot for element <AXUIElement 0x1004357f0> {pid=6595}}

Proper test reporting.

There should be some way to capture tap and other gesture events in either TestSummary.plist file or in some other reporting tool. Current implementation limits the use of SwiftMonkey to development machines if there is no reporting, then its hard to go back and see what happened during failure.

I want to testing swiftMonkey on a real Device.

I have do like this,but it does not work! You see.

======================================

Hi @monkeytest15! It's great to hear that you like the tool :) I am also happy to inform you that testing on a real device should be already possible! Just grab the latest changes from master and you should be all set.If you are using CocoaPods to integrate the library just type in your Podfile:pod 'SwiftMonkey', :git => 'https://github.com/zalando/SwiftMonkey.git'The latest master version of SwiftMonkey is not yet released to CocoaPods repository. We should do this soon and then you won't need to explicitly specify the repository URL.

test failed

2018-09-20 16:47:44.135358+0800 SwiftMonkeyExampleUITests-Runner[4876:449144] +[CATransaction synchronize] called within transaction
2018-09-20 16:47:44.349712+0800 SwiftMonkeyExampleUITests-Runner[4876:449144] Running tests...
2018-09-20 16:47:45.321244+0800 SwiftMonkeyExampleUITests-Runner[4876:449144] The bundle “SwiftMonkeyExampleUITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2018-09-20 16:47:45.321450+0800 SwiftMonkeyExampleUITests-Runner[4876:449144] (dlopen_preflight(/Users/ios/Library/Developer/Xcode/DerivedData/SwiftMonkeyExample-guvnsrsjlufdsbdsgqhebbunpfij/Build/Products/Debug-iphonesimulator/SwiftMonkeyExampleUITests-Runner.app/PlugIns/SwiftMonkeyExampleUITests.xctest/SwiftMonkeyExampleUITests): Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib
Referenced from: /Users/ios/Library/Developer/Xcode/DerivedData/SwiftMonkeyExample-guvnsrsjlufdsbdsgqhebbunpfij/Build/Products/Debug-iphonesimulator/SwiftMonkey.framework/SwiftMonkey
Reason: no suitable image found. Did find:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftSwiftOnoneSupport.dylib: mach-o, but not built for iOS simulator)

Function Does Not Work for Location Services Popup

public func addXCTestTapAlertAction(interval: Int, application: XCUIApplication) {

This function works fine for all other alerts such as alerts generated by application under test but it does not tap on the location services pop up. When I debugged the issue I found that alert.count is returning 0 when location pop up appears that caused the skipping of this function. If we can find a way to identify location pop-ups, which are not different from any other alert types, then this issue will be resolved.

I tried using the alert description to identify the alert and in that case tap worked just fine but other than that I was not able to identify alerts if I am not using alert description.

This is the pop up I was referring

screen shot 2018-07-06 at 4 59 22 pm

How to find out the seed number?

I use random seed numbers to start test.
How to figure out seed number when app is crashing? to reproduce test with this seed number.

Fix swipe actions to avoid pulling out the top and bottom panels

The swipe actions can accidentally pull out panels from the top or bottom, which can let the monkey escape from the app, which can create more havoc than desired.

This could probably be fixed by avoiding certain coordinates when generating random swipes.

[Crash] Framework not work when UI launch

When UILauch this method monkey.monkeyAround(iterations: 200) then crash and i have this error.

[MonkeyUITests testMonkey()] failed: failed: caught "NSInvalidArgumentException", "*** -[NSXPCEncoder _checkObject:]: This coder only encodes objects that adopt NSSecureCoding (object is of class 'NSMallocBlock')."
(
0 CoreFoundation 0x00bc7a94 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x00688e02 objc_exception_throw + 50
2 CoreFoundation 0x00bc79bd +[NSException raise:format:] + 141
3 Foundation 0x002c76fc -[NSXPCEncoder _checkObject:] + 366
4 Foundation 0x002c7334 -[NSXPCEncoder encodeObject:forKey:] + 67
5 XCTest 0x00155938 -[XCSynthesizedEventRecord encodeWithCoder:] + 49
6 Foundation 0x002c7c8b -[NSXPCEncoder encodeObject:] + 665
7 Foundation 0x002c7378 -[NSXPCEncoder encodeObject:forKey:] + 135
8 Foundation 0x002c8068 -[NSXPCEncoder encodeObject:] + 48
9 Foundation 0x002bd203 walkAndEncodeData + 1303
10 Foundation 0x002bcb36 encodeInvocationArguments + 298
11 Foundation 0x002c7e4e -[NSXPCEncoder encodeInvocation:] + 406
12 Foundation 0x002c7c8b -[NSXPCEncoder encodeObject:] + 665
13 Foundation 0x002c7378 -[NSXPCEncoder encodeObject:forKey:] + 135
14 Foundation 0x004667cf -[NSXPCConnection sendInvocation:withProxy:remoteInterface:withErrorHandler:timeout:userInfo:] + 3322
15 Foundation 0x00465a13 -[NSXPCConnection sendInvocation:withProxy:remoteInterface:] + 88
16 Foundation 0x002c6ca1 -[NSXPCDistantObject forwardInvocation:] + 97
17 CoreFoundation 0x00b0ec08 forwarding + 472
18 CoreFoundation 0x00b0ea0e CF_forwarding_prep_0 + 14
19 XCTest 0x0016541b -[XCEventGenerator pressAtPoint:forDuration:liftAtPoint:velocity:orientation:name:handler:] + 560
20 SwiftMonkey 0x0c006f93 TFFC11SwiftMonkey6Monkey19addXCTestDragActionFT6weightSd_T_U_FT_T + 1187
21 SwiftMonkey 0x0bffd739 TTRXFo___XFo_iT__iT + 25
22 SwiftMonkey 0x0bffd7ff TPA__TTRXFo___XFo_iT__iT + 95
23 SwiftMonkey 0x0bffcf05 TTRXFo_iT__iT__XFo + 21
24 SwiftMonkey 0x0bffcfed TPA__TTRXFo_iT__iT__XFo + 61
25 SwiftMonkey 0x0bffcd60 TFC11SwiftMonkey6Monkey11actRandomlyfT_T + 736
26 SwiftMonkey 0x0bffc9df TFC11SwiftMonkey6Monkey12monkeyAroundfT10iterationsSi_T + 335
27 OpenFleetUITests 0x0bf899a1 TFC16OpenFleetUITests13MonkeyUITests10testMonkeyfT_T + 1409
28 OpenFleetUITests 0x0bf89a32 TToFC16OpenFleetUITests13MonkeyUITests10testMonkeyfT_T + 34
29 CoreFoundation 0x00a9fccd invoking + 29
30 CoreFoundation 0x00a9fb76 -[NSInvocation invoke] + 342
31 XCTest 0x0015b4d7 __24-[XCTestCase invokeTest]_block_invoke_2 + 470
32 XCTest 0x00196dab -[XCTestContext performInScope:] + 229
33 XCTest 0x0015b2f4 -[XCTestCase invokeTest] + 269
34 XCTest 0x0015bbec -[XCTestCase performTest:] + 515
35 XCTest 0x00186a4f -[XCTest runTest] + 48
36 XCTest 0x00158936 -[XCTestSuite performTest:] + 488
37 XCTest 0x00186a4f -[XCTest runTest] + 48
38 XCTest 0x00158936 -[XCTestSuite performTest:] + 488
39 XCTest 0x00186a4f -[XCTest runTest] + 48
40 XCTest 0x00158936 -[XCTestSuite performTest:] + 488
41 XCTest 0x00186a4f -[XCTest runTest] + 48
42 XCTest 0x0014322d __25-[XCTestDriver _runSuite]_block_invoke + 61
43 XCTest 0x0016755b -[XCTestObservationCenter _observeTestExecutionForBlock:] + 663
44 XCTest 0x00143090 -[XCTestDriver _runSuite] + 510
45 XCTest 0x00144118 -[XCTestDriver _checkForTestManager] + 290
46 XCTest 0x00144518 -[XCTestDriver runTestConfiguration:completionHandler:] + 325
47 XCTest 0x0019834b _XCTestMain + 642
48 XCTRunner 0x00050b58 XCTRunner + 7000
49 CoreFoundation 0x00ae1e60 CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 16
50 CoreFoundation 0x00ad77e3 __CFRunLoopDoBlocks + 195
51 CoreFoundation 0x00ad6f18 __CFRunLoopRun + 1016
52 CoreFoundation 0x00ad6866 CFRunLoopRunSpecific + 470
53 CoreFoundation 0x00ad667b CFRunLoopRunInMode + 123
54 GraphicsServices 0x0262f664 GSEventRunModal + 192
55 GraphicsServices 0x0262f4a1 GSEventRun + 104
56 UIKit 0x00f56cc1 UIApplicationMain + 160
57 XCTRunner 0x00050cce XCTRunner + 7374
58 libdyld.dylib 0x02ddaa21 start + 1
)

Ability to exclude XCUIElements from being tapped

Firstly, thanks for this, it's a great tool, working generally fairly well for me in the few test runs I've used it for.

Secondly, apologies if this is covered in the framework already, I took a look at the Monkey.swift file and could see randomPointAvoidingPanelAreas, but that's not quite what I'd be after here (I think!)

Context for my request:
There's a few parts of my app I don't want the 'monkey' to tap: eg, links to webviews (which open Safari), links to other apps (eg: out to Maps), log out buttons (which we'd normally not want tapped, as our app largely needs to be tested while 'logged-in'), or even debug-build specific tap areas where we nest 'admin' functionality, etc, etc. When the 'monkey' taps these areas, the test is either invalid (I don't want the 'monkey' testing Apple Maps), or becomes not as interesting to me (eg: if logged-out, I don't care as much about what the 'monkey' finds)

Request:

  • Create a dictionary of items that need to be ignored by the 'monkey', perhaps as a list of XCUIElements.
  • Have the 'monkey' check for existence of items in this dictionary, and avoid these if the dictionary's populated
  • Continue on as-usual, if nothing's in the dictionary?
    Or something like that maybe? The gist is: a way to exclude specific XCUIElements from tap events.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.