Skip to content

Commit f9ab96b

Browse files
committed
2 parents 613a2d8 + 640a3fe commit f9ab96b

File tree

1 file changed

+127
-3
lines changed

1 file changed

+127
-3
lines changed

README.md

Lines changed: 127 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ Kraken is an open source automated android E2E testing tool that supports and va
66

77
Kraken uses [calabash-android](https://github.com/calabash/calabash-android) for running automated E2E tests in each device or emulator and [cucumber](https://github.com/cucumber/cucumber-ruby) for running your feature files written with Gherkin sintax.
88

9-
**Requires Ruby ~ 2.3**
10-
119
## Installation
1210

13-
Installing and managing a Gem is done through the gem command. To Kraken's gem run the following command
11+
### Prerequisites
12+
13+
Kraken requires Ruby 2.20 or higher but we recommend using ~2.3 version. We use calabash-android as runner, you can check their prerequisites at this [link](https://github.com/calabash/calabash-android/blob/master/documentation/installation.md)
14+
15+
16+
Installing and managing a Gem is done through the gem command. To install Kraken's gem run the following command
1417

1518
$ gem install kraken-mobile
1619

@@ -21,8 +24,129 @@ Signaling is a protocol used for the communication of two or more devices runnin
2124

2225
## Writing your first test
2326

27+
### Generate cucumber feature skeleton
28+
29+
First you need to generate the cucumber feature skeleton where your tests are going to be saved. To achieve this you should run `kraken-mobile gen`. It will create the skeleton in your current folder like this:
30+
31+
features
32+
|_support
33+
| |_app_installation_hooks.rb
34+
| |_app_life_cycle_hooks.rb
35+
| |_env.rb
36+
|_step_definitions
37+
| |_kraken_steps.rb
38+
|_my_first.feature
39+
40+
### Write a test
41+
42+
The features goes in the features foler and should have the ".feature" extension.
43+
44+
You can start out by looking at features/my_first.feature. You should also check calabash [predefined steps](https://github.com/calabash/calabash-android/blob/master/ruby-gem/lib/calabash-android/canned_steps.md).
45+
46+
### Syntax
47+
48+
In Kraken each feature is a test and each scenario within a feature is a test case that is run in a device. Each device is identified as an user and numbered from 1 to N. Ex: @user1, @user2, @user3. To check what is the number of a given device you should run `kraken-mobile devices`
49+
50+
List of devices attached
51+
user1 - emulator-5554 - Android_SDK_built_for_x86
52+
user2 - emulator-5556 - Android_SDK_built_for_x86
53+
54+
After identifying what number each device has, you can write your test case giving each scenario the tag of a given device like so:
55+
56+
Feature: Example feature
57+
58+
@user1
59+
Scenario: As a first user I say hi to a second user
60+
Given I wait
61+
Then I send a signal to user 2 containing "hi"
62+
63+
@user2
64+
Scenario: As a second user I wait for user 1 to say hi
65+
Given I wait for a signal containing "hi"
66+
Then I wait
67+
68+
## Kraken steps
69+
70+
Kraken offers two main steps to help synchronizing your devices.
71+
72+
### Signaling steps
73+
74+
To wait for a signal coming from another device for 10 seconds that is Kraken default timeout use the following step.
75+
76+
Then /^I wait for a signal containing "([^\"]*)"$/
77+
78+
To wait for a signal coming from another device for an specified number of seconds use the following step
79+
80+
Then /^I wait for a signal containing "([^\"]*)" for (\d+) seconds$/
81+
82+
To send a signal to another specified device use the following step
83+
84+
Then /^I send a signal to user (\d+) containing "([^\"]*)"$/
85+
86+
### Signaling functions
87+
88+
Kraken internal implementation of the signaling steps use the following functions.
89+
90+
#### readSignal(channel, content, timeout)
91+
92+
Waits for a signal with the specified content in the channel passed by parameter. This functions waits for the specified number of seconds in the timeout parameter before throwing an exception.
93+
94+
**Note: The channel parameter has to be the number of a device such as @user1, @user2, @userN**
95+
96+
#### writeSignal(channel, content)
97+
98+
Writes content to a channel passed by parameter.
99+
100+
**Note: The channel parameter has to be the number of a device such as @user1, @user2, @userN**
101+
24102
## Running your tests
25103

104+
To run your test:
105+
106+
kraken-mobile run <apk>
107+
108+
Kraken with the help of Calabash-Android will install an instrumentation along with your app and will start your tests in all devices connected (Check Kraken Settings section in order to learn how to specify in what devices your tests should be run).
109+
26110
## Kraken Settings
27111

112+
Kraken uses kraken_mobile_settings.json to specify in what devices the tests should be run.
113+
114+
### Generate settings file
115+
116+
The following command will show you the available connected devices or emulators and let you choose which ones you want to use.
117+
118+
kraken-mobile setup
119+
120+
### Run tests with settings file
121+
122+
kraken-mobile run <apk> --configuration=<kraken_mobile_settings_path>
123+
28124
## Properties file
125+
126+
Kraken uses properties files to store sensitive data such as passwords or api keys that should be used in your test cases.
127+
128+
### Generate properties file
129+
130+
The properties files should be a manually created json file with the following structure.
131+
132+
{
133+
"@user1": {
134+
"PASSWORD": "test"
135+
},
136+
"@user2": {
137+
"PASSWORD": "test2"
138+
}
139+
}
140+
141+
### Use properties file in your test
142+
143+
You can use the specified properties using the following sintax.
144+
145+
@user1
146+
Scenario: As a kjkhdkjds
147+
Given I wait
148+
Then I see the text "<PASSWORD>"
149+
150+
### Run tests with settings file
151+
152+
kraken-mobile run <apk> --properties=<kraken_mobile_properties_path>

0 commit comments

Comments
 (0)