forked from hunterno4/spoon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
480 additions
and
469 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,177 +1,184 @@ | ||
Spoon | ||
===== | ||
|
||
Distributing instrumentation tests to all your Androids. | ||
|
||
|
||
|
||
Introduction | ||
------------ | ||
|
||
Android's ever-expanding ecosystem of devices creates a unique challenge to | ||
testing applications. Spoon aims to simplify this task by distributing | ||
instrumentation test execution and displaying the results in a meaningful way. | ||
|
||
Instead of attempting to be a new form of testing, Spoon makes existing | ||
instrumentation tests more useful. Using the application APK and instrumentation | ||
APK, Spoon runs the tests on multiple devices simultaneously. Once all tests | ||
have completed a static HTML summary is generated with detailed information | ||
about each device and test. | ||
|
||
 | ||
|
||
Spoon will run on all targets which are visible to `adb devices`. Plug in | ||
multiple different phones and tablets, start different configurations of | ||
emulators, or use some combination of both! | ||
|
||
The greater diversity of the targets in use, the more useful the output will be | ||
in visualizing your applications. | ||
|
||
|
||
|
||
Screenshots | ||
----------- | ||
|
||
In addition to simply running instrumentation tests, Spoon has the ability to | ||
snap screenshots at key points during your tests which are then included in the | ||
output. This allows for visual inspection of test executions across different | ||
devices. | ||
|
||
Taking screenshots requires that you include the `spoon-client` JAR in your | ||
instrumentation app. In your tests call the `screenshot` method with a | ||
human-readable tag. | ||
|
||
```java | ||
Spoon.screenshot(activity, "initial_state"); | ||
/* Normal test code... */ | ||
Spoon.screenshot(activity, "after_login"); | ||
``` | ||
|
||
The tag specified will be used to identify and compare screenshots taken across | ||
multiple test runs. | ||
|
||
 | ||
|
||
You can also view each test's screenshots as an animated GIF to gauge the actual | ||
sequence of interaction. | ||
|
||
|
||
|
||
Download | ||
-------- | ||
|
||
Download the [latest runner JAR][1] or the [latest client JAR][2], or grab | ||
via Maven: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.squareup.spoon</groupId> | ||
<artifactId>spoon-client</artifactId> | ||
<version>1.1.1</version> | ||
</dependency> | ||
``` | ||
|
||
Snapshots of the development version are available in [Sonatype's `snapshots` repository][snap]. | ||
|
||
|
||
|
||
Execution | ||
--------- | ||
|
||
Spoon was designed to be run both as a standalone tool or directly as part of | ||
your build system. | ||
|
||
You can run Spoon as a standalone tool with your application and instrumentation | ||
APKs. | ||
|
||
``` | ||
java -jar spoon-runner-1.1.1-jar-with-dependencies.jar \ | ||
--apk example-app.apk \ | ||
--test-apk example-tests.apk | ||
``` | ||
|
||
By default the output will be placed in a spoon-output/ folder of the current | ||
directory. You can control additional parameters of the execution using other | ||
flags. | ||
|
||
``` | ||
Options: | ||
--apk Application APK | ||
--fail-on-failure Non-zero exit code on failure | ||
--output Output path | ||
--sdk Path to Android SDK | ||
--test-apk Test application APK | ||
--title Execution title | ||
--class-name Test class name to run (fully-qualified) | ||
--method-name Test method name to run (must also use --class-name) | ||
--no-animations Disable animated gif generation | ||
--size Only run test methods annotated by testSize (small, medium, large) | ||
--adb-timeout Set maximum execution time per test in seconds (10min default) | ||
``` | ||
|
||
If you are using Maven for compilation, a plugin is provided for easy execution. | ||
Declare the plugin in the `pom.xml` for the instrumentation test module. | ||
|
||
```xml | ||
<plugin> | ||
<groupId>com.squareup.spoon</groupId> | ||
<artifactId>spoon-maven-plugin</artifactId> | ||
<version>1.1.1</version> | ||
</plugin> | ||
``` | ||
|
||
The plugin will look for an `apk` dependency for the corresponding application. | ||
Typically this is specified in parallel with the `jar` dependency on the | ||
application. | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.example</groupId> | ||
<artifactId>example-app</artifactId> | ||
<version>${project.version}</version> | ||
<type>jar</type> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.example</groupId> | ||
<artifactId>example-app</artifactId> | ||
<version>${project.version}</version> | ||
<type>apk</type> | ||
<scope>provided</scope> | ||
</dependency> | ||
``` | ||
|
||
You can invoke the plugin by running `mvn spoon:run`. The execution result will | ||
be placed in the `target/spoon-output/` folder. If you want to specify a test | ||
class to run, add `-Dspoon.test.class=fully.qualified.ClassName`. If you only | ||
want to run a single test in that class, add `-Dspoon.test.method=testAllTheThings`. | ||
|
||
For a working example see the sample application and instrumentation tests in | ||
the `spoon-sample/` folder. | ||
|
||
|
||
|
||
License | ||
-------- | ||
|
||
Copyright 2013 Square, Inc. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
|
||
|
||
|
||
[1]: https://search.maven.org/remote_content?g=com.squareup.spoon&a=spoon-runner&v=LATEST&c=jar-with-dependencies | ||
[2]: https://search.maven.org/remote_content?g=com.squareup.spoon&a=spoon-client&v=LATEST | ||
[snap]: https://oss.sonatype.org/content/repositories/snapshots/ | ||
|
||
Spoon | ||
===== | ||
|
||
Distributing instrumentation tests to all your Androids. | ||
|
||
|
||
|
||
Introduction | ||
------------ | ||
|
||
Android's ever-expanding ecosystem of devices creates a unique challenge to | ||
testing applications. Spoon aims to simplify this task by distributing | ||
instrumentation test execution and displaying the results in a meaningful way. | ||
|
||
Instead of attempting to be a new form of testing, Spoon makes existing | ||
instrumentation tests more useful. Using the application APK and instrumentation | ||
APK, Spoon runs the tests on multiple devices simultaneously. Once all tests | ||
have completed a static HTML summary is generated with detailed information | ||
about each device and test. | ||
|
||
 | ||
|
||
Spoon will run on all targets which are visible to `adb devices`. Plug in | ||
multiple different phones and tablets, start different configurations of | ||
emulators, or use some combination of both! | ||
|
||
The greater diversity of the targets in use, the more useful the output will be | ||
in visualizing your applications. | ||
|
||
|
||
|
||
Screenshots | ||
----------- | ||
|
||
In addition to simply running instrumentation tests, Spoon has the ability to | ||
snap screenshots at key points during your tests which are then included in the | ||
output. This allows for visual inspection of test executions across different | ||
devices. | ||
|
||
Taking screenshots requires that you include the `spoon-client` JAR in your | ||
instrumentation app. In your tests call the `screenshot` method with a | ||
human-readable tag. | ||
|
||
```java | ||
Spoon.screenshot(activity, "initial_state"); | ||
/* Normal test code... */ | ||
Spoon.screenshot(activity, "after_login"); | ||
``` | ||
|
||
The tag specified will be used to identify and compare screenshots taken across | ||
multiple test runs. | ||
|
||
 | ||
|
||
You can also view each test's screenshots as an animated GIF to gauge the actual | ||
sequence of interaction. | ||
|
||
|
||
|
||
Download | ||
-------- | ||
|
||
Download the [latest runner JAR][1] or the [latest client JAR][2], or grab | ||
via Maven: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.squareup.spoon</groupId> | ||
<artifactId>spoon-client</artifactId> | ||
<version>1.1.1</version> | ||
</dependency> | ||
``` | ||
|
||
Snapshots of the development version are available in [Sonatype's `snapshots` repository][snap]. | ||
|
||
|
||
|
||
Execution | ||
--------- | ||
|
||
Spoon was designed to be run both as a standalone tool or directly as part of | ||
your build system. | ||
|
||
You can run Spoon as a standalone tool with your application and instrumentation | ||
APKs. | ||
|
||
``` | ||
原来的使用方式: | ||
java -jar spoon-runner-1.1.1-jar-with-dependencies.jar \ | ||
--apk example-app.apk \ | ||
--test-apk example-tests.apk | ||
推荐的使用方式: | ||
java -jar spoon-runner-1.1.3-SNAPSHOT-jar-with-dependencies.jar \ | ||
--apk spoon-sample-app-1.1.3-SNAPSHOT.apk \ | ||
--test-apk spoon-sample-tests-1.1.3-SNAPSHOT.apk \ | ||
--class-name com.example.spoon.ordering.tests.LoginActivityTest,com.example.spoon.ordering.tests.MiscellaneousTest | ||
多个用例集用,号隔开 | ||
``` | ||
|
||
By default the output will be placed in a spoon-output/ folder of the current | ||
directory. You can control additional parameters of the execution using other | ||
flags. | ||
|
||
``` | ||
Options: | ||
--apk Application APK | ||
--fail-on-failure Non-zero exit code on failure | ||
--output Output path | ||
--sdk Path to Android SDK | ||
--test-apk Test application APK | ||
--title Execution title | ||
--class-name Test class name to run (fully-qualified) | ||
--method-name Test method name to run (must also use --class-name) | ||
--no-animations Disable animated gif generation | ||
--size Only run test methods annotated by testSize (small, medium, large) | ||
--adb-timeout Set maximum execution time per test in seconds (10min default) | ||
``` | ||
|
||
If you are using Maven for compilation, a plugin is provided for easy execution. | ||
Declare the plugin in the `pom.xml` for the instrumentation test module. | ||
|
||
```xml | ||
<plugin> | ||
<groupId>com.squareup.spoon</groupId> | ||
<artifactId>spoon-maven-plugin</artifactId> | ||
<version>1.1.1</version> | ||
</plugin> | ||
``` | ||
|
||
The plugin will look for an `apk` dependency for the corresponding application. | ||
Typically this is specified in parallel with the `jar` dependency on the | ||
application. | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.example</groupId> | ||
<artifactId>example-app</artifactId> | ||
<version>${project.version}</version> | ||
<type>jar</type> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.example</groupId> | ||
<artifactId>example-app</artifactId> | ||
<version>${project.version}</version> | ||
<type>apk</type> | ||
<scope>provided</scope> | ||
</dependency> | ||
``` | ||
|
||
You can invoke the plugin by running `mvn spoon:run`. The execution result will | ||
be placed in the `target/spoon-output/` folder. If you want to specify a test | ||
class to run, add `-Dspoon.test.class=fully.qualified.ClassName`. If you only | ||
want to run a single test in that class, add `-Dspoon.test.method=testAllTheThings`. | ||
|
||
For a working example see the sample application and instrumentation tests in | ||
the `spoon-sample/` folder. | ||
|
||
|
||
|
||
License | ||
-------- | ||
|
||
Copyright 2013 Square, Inc. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
|
||
|
||
|
||
[1]: https://search.maven.org/remote_content?g=com.squareup.spoon&a=spoon-runner&v=LATEST&c=jar-with-dependencies | ||
[2]: https://search.maven.org/remote_content?g=com.squareup.spoon&a=spoon-client&v=LATEST | ||
[snap]: https://oss.sonatype.org/content/repositories/snapshots/ | ||
|
Oops, something went wrong.