https://github.com/alexmx/insider
Insider sets a backdoor into your app for testing tools like XCTest, Appium, Calabash, etc.
https://github.com/alexmx/insider
appium automation-test calabash frank ios testing testing-framework testing-tools
Last synced: 9 months ago
JSON representation
Insider sets a backdoor into your app for testing tools like XCTest, Appium, Calabash, etc.
- Host: GitHub
- URL: https://github.com/alexmx/insider
- Owner: alexmx
- License: mit
- Archived: true
- Created: 2016-02-16T16:52:27.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-06-22T14:16:22.000Z (about 8 years ago)
- Last Synced: 2025-09-11T23:27:06.248Z (10 months ago)
- Topics: appium, automation-test, calabash, frank, ios, testing, testing-framework, testing-tools
- Language: Objective-C
- Homepage: http://alexmx.github.io/Insider
- Size: 636 KB
- Stars: 23
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Insider
[](https://travis-ci.org/alexmx/Insider)
[](https://twitter.com/amaimescu)
[](https://github.com/alexmx/ios-ui-automation-overview/blob/master/LICENSE)
Insider is an utility framework which sets a **backdoor** into your app for testing tools like [Appium](http://appium.io/), [Calabash](http://calaba.sh/), [Frank](http://www.testingwithfrank.com/), etc.
## Why do I need this?
There are many scenarios which are hard to cover during the automation testing because the testing environment is isolated from the tested app:
* Set a particular state for the app during the test scenario;
* Simulate push notifications;
* Simulate app invocation using custom schemes / universal links;
* Simulate handoff invocations;
* Manage files / directories in application sandbox;
* Collect metrics from the app during test execution (CPU, memory, etc.);
* etc.
Insider runs an HTTP server inside the application and listens for commands (RPCs). By default, Insider runs on `http://localhost:8080`.
A command represents a simple HTTP request: `http://localhost:8080/`. You can pre-configure your app to simulate an action when it receives such a remote command.
## Features
| | Built-in Features | Commands | HTTP Method
------------ | ------------- | ------------- | -------------
🚚 | Send a message (dictionary) to the app; | `/send` | POST
🚌 | Send a message to the app and wait for response; | `/sendAndWaitForResponse` | POST
📢 | Send local notifications through **NSNotificationCenter** with given parameters; | `/notification` | POST
📱 | Get device system state information (CPU, memory, IP address, etc); | `/systemInfo` | GET
:floppy_disk: | Manage files / directories in application sandbox (Documents, Library, tmp); | `/documents/`
`/library/`
`/tmp/` | See the table below
Supported commands for file managing feature:
File Managing Commands | HTTP Method
------------ | -------------
List items: `//list` | GET
Download items: `//download` | GET
Upload items: `//upload` | POST
Move items: `//move` | POST
Delete items: `//delete` | POST
Create folder: `//create` | POST
In the `scripts` directory can be found sample ruby scripts which show the built-in features in action.
Check out the [API reference](http://alexmx.github.io/Insider/) for more information.
## Installation
#### Manual installation
In order to include the **Insider** library into your project, you need to build a dynamic framework from provided source code and include it into your project, or inlcude the entire **Insider** library as sub-project by copying it to your project directory or include as Git submodule.
#### Carthage
If you are using **Carthage**, you can always use it to build the library within your workspace by adding the line below to your `Cartfile`.
```
github "alexmx/Insider"
```
#### CocoaPods
If you are using **CocoaPods**, you can as well use it to integrate the library by adding the following lines to your `Podfile`.
```ruby
platform :ios, '8.0'
use_frameworks!
target 'YourAppTarget' do
pod "Insider"
end
```
## Usage
#### Use case #1: Simulate Push Notifications
```swift
import Insider
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Launch the Isider with the given delegate
Insider.shared.start(withDelegate: self)
return true
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
// Process push notification
}
}
extension AppDelegate: InsiderDelegate {
// This delegate method is invoked when a remote message is sent to the app
func insider(_ insider: Insider, didReceiveRemote message: InsiderMessage?) {
// Simulate push notification
application(UIApplication.shared, didReceiveRemoteNotification: message!)
}
}
```
In order to test this example run `InsiderDemo` application target, after go to `scripts` directory and run `send_message.rb` script.
#### Use case #2: Simulate app invocation using a custom scheme
```swift
import Insider
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Insider.shared.start(withDelegate: self)
return true
}
func application(_ application: UIApplication, handleOpen url: URL) -> Bool {
// Process custom scheme invocation
return true
}
}
extension AppDelegate: InsiderDelegate {
func insider(_ insider: Insider, returnResponseMessageForRemote message: InsiderMessage?) -> InsiderMessage? {
// Simulate app invocation using a custom scheme
let url = URL(string: "insiderDemo://hello/params")
let response = application(UIApplication.shared, handleOpen: url!)
return ["response" as NSObject : response as AnyObject]
}
}
```
In order to test this example run `InsiderDemo` application target, after go to `scripts` directory and run `send_message_with_response.rb` script.
#### Use case #3: Get application system information during test execution
```swift
import Insider
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Insider.shared.start()
return true
}
}
```
As it is a built-in feature there is no need to set a delegate for Insider in this case. In order to test this example run `InsiderDemo` application target, after go to `scripts` directory and run `system_info.rb` script.
#### Use case #4: Add files to Documents folder in application sandbox.
```swift
import Insider
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Insider.shared.start()
return true
}
}
```
As it is a built-in feature there is no need to set a delegate for Insider in this case.
There are 3 directories supported in application sandbox:
* **Documents**: `http://localhost:8080/documents`
* **Library**: `http://localhost:8080/library`
* **tmp**: `http://localhost:8080/tmp`
You can create new folders. Upload, download, move, remove files / folders from application sandbox.
In order to test this example run `InsiderDemo` application target, and open in your browser:
* [http://localhost:8080/documents](http://localhost:8080/documents),
* [http://localhost:8080/library](http://localhost:8080/library)
* [http://localhost:8080/tmp](http://localhost:8080/tmp)
You will see the files which are in your application sandbox.

If you need to use the sandbox files managing API in your automation scripts please check **File Managing Commands** section above.
## Credits
**Insider** uses these amazing libaries under the hood:
* [GCDWebServer](https://github.com/swisspol/GCDWebServer)
* [iOS-System-Services](https://github.com/Shmoopi/iOS-System-Services)
## License
This project is licensed under the terms of the MIT license. See the LICENSE file.