Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
Add documentation and bump version to 1.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dag Ågren committed Nov 28, 2016
1 parent 65548ec commit 677b188
Show file tree
Hide file tree
Showing 64 changed files with 8,543 additions and 57 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.build
build
xcuserdata

15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,17 @@ early on in your program execution:
var paws: MonkeyPaws?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
paws = MonkeyPaws(view: window!)
return true
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.)
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.)

This call will swizzle some methods in UIApplication to capture
UIEvents. If you would rather not do this, or if you already have
Expand All @@ -172,13 +176,10 @@ to disable swizzling:
paws = MonkeyPaws(view: window!, tapUIApplication: false)
````

Then you can pass in events or touches with either of the
following calls:
Then you can pass in events with the following call:

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

paws?.append(touch: touch) // touch is UITouch
````

## Contributing
Expand Down
2 changes: 1 addition & 1 deletion SwiftMonkey.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SwiftMonkey"
s.version = "0.2.0"
s.version = "1.0.0"
s.summary = "Monkey testing framework for iOS apps"
s.description = <<-DESC
A framework for generating randomised user
Expand Down
135 changes: 135 additions & 0 deletions SwiftMonkey/Documentation/Classes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Classes Reference</title>
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
<meta charset='utf-8'>
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>

</head>
<body>
<a title="Classes Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="index.html"> Docs</a> (100% documented)</p>
</div>
</header>
<div class="content-wrapper">
<p id="breadcrumbs">
<a href="index.html"> Reference</a>
<img id="carat" src="img/carat.png" />
Classes Reference
</p>
</div>
<div class="content-wrapper">
<nav class="sidebar">
<ul class="nav-groups">
<li class="nav-group-name">
<a href="Classes.html">Classes</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Classes/Monkey.html">Monkey</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section>
<section class="section">
<h1>Classes</h1>
<p>The following classes are available globally.</p>

</section>
<section class="section task-group-section">
<div class="task-group">
<ul>
<li class="item">
<div>
<code>
<a name="/s:C11SwiftMonkey6Monkey"></a>
<a name="//apple_ref/swift/Class/Monkey" class="dashAnchor"></a>
<a class="token" href="#/s:C11SwiftMonkey6Monkey">Monkey</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A general-purpose class for implementing randomised
UI tests. This class lets you schedule blocks to be
run at random or fixed intervals, and provides helper
functions to generate random coordinates.</p>

<p>It has several extensions that implement actual event
generation, using different methods. For normal usage,
you will want to look at for instance the XCTest private
API based extension.</p>

<p>If all you want to do is geneate some events and you do
not care about the finer details, you can just use a
test case like the following:</p>

<pre class="highlight plaintext"><code>func testMonkey() {
let application = XCUIApplication()

// Workaround for bug in Xcode 7.3. Snapshots are not properly updated
// when you initially call app.frame, resulting in a zero-sized rect.
// Doing a random query seems to update everything properly.
// TODO: Remove this when the Xcode bug is fixed!
_ = application.descendants(matching: .any).element(boundBy: 0).frame

// 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.
// UIAutomation actions seem to work only on the simulator.
monkey.addDefaultXCTestPrivateActions()
//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()
}
</code></pre>

<a href="Classes/Monkey.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">Monkey</span></code></pre>

</div>
</div>
</section>
</div>
</li>
</ul>
</div>
</section>
</section>
<section id="footer">
<p>&copy; 2016 <a class="link" href="" target="_blank" rel="external"></a>. All rights reserved. (Last updated: 2016-11-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>
</body>
</div>
</html>
Loading

0 comments on commit 677b188

Please sign in to comment.