diff --git a/.gitignore b/.gitignore index 508b6f0..a0a2aa6 100644 --- a/.gitignore +++ b/.gitignore @@ -31,7 +31,7 @@ release.properties #Intelli J project files .idea/ -.iml +*.iml #Maven project files target/ diff --git a/README.md b/README.md index 27067ca..b990527 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,15 @@ mvn clean install -P spoon Here is the result in a browser : +## Espresso run with Spoon + +To build the sample project and run the sample app using Spoon : + +```bash +# in parent folder +mvn clean install -P espresso-spoon +``` + ## Monkey testing Monkey is part of Android SDK and allows to harness Application UI and test their robustness. diff --git a/android-sample-espresso-spoon-tests/AndroidManifest.xml b/android-sample-espresso-spoon-tests/AndroidManifest.xml new file mode 100644 index 0000000..e1853f5 --- /dev/null +++ b/android-sample-espresso-spoon-tests/AndroidManifest.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/android-sample-espresso-spoon-tests/build.xml b/android-sample-espresso-spoon-tests/build.xml new file mode 100644 index 0000000..8fb60f4 --- /dev/null +++ b/android-sample-espresso-spoon-tests/build.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android-sample-espresso-spoon-tests/pom.xml b/android-sample-espresso-spoon-tests/pom.xml new file mode 100644 index 0000000..23a3316 --- /dev/null +++ b/android-sample-espresso-spoon-tests/pom.xml @@ -0,0 +1,218 @@ + + + 4.0.0 + + + com.octo.android + android-sample-parent + 0.0.1-SNAPSHOT + + + android-sample-espresso-spoon-tests + apk + android-sample-espresso-spoon-tests + + + 1.8 + + + + + + project.local + project + file:${project.basedir}/repo + + + + + + android + android + + + android.support + compatibility-v4 + provided + + + com.octo.android + android-sample + ${project.version} + jar + provided + + + com.octo.android + android-sample + ${project.version} + apk + provided + + + + com.google.android + android-espresso + 1.0-SNAPSHOT + + + com.squareup.spoon + spoon-client + + + + + + + true + com.jayway.maven.plugins.android.generation2 + android-maven-plugin + + + + maven-compiler-plugin + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${project.build.directory}/generated-sources/annotations/ + + + + + + + maven-compiler-plugin + + ${java.version} + ${java.version} + + + + maven-pmd-plugin + + true + + + + + + + + + emma + + + emma + emma + + + + + + com.jayway.maven.plugins.android.generation2 + android-maven-plugin + + + true + true + + + true + + + pull-coverage + post-integration-test + + pull + + + /data/data/com.octo.android.sample/files/coverage.ec + ${project.basedir}/../android-sample/target/emma/coverage.ec + + + + + + + + + espresso-spoon + + + + com.jayway.maven.plugins.android.generation2 + android-maven-plugin + true + + true + + + + + com.squareup.spoon + spoon-maven-plugin + ${spoon.version} + + Spoon Sample App + true + + + + integration-test + + run + + + + + + + + + jacoco + + + + com.jayway.maven.plugins.android.generation2 + android-maven-plugin + + + + true + + + true + true + + + + + pull-coverage + post-integration-test + + pull + + + /data/data/com.octo.android.sample/files/coverage.ec + ${project.basedir}/../android-sample/target/jacoco-it.exec + + + + + + + + + + diff --git a/android-sample-espresso-spoon-tests/project.properties b/android-sample-espresso-spoon-tests/project.properties new file mode 100644 index 0000000..a3ee5ab --- /dev/null +++ b/android-sample-espresso-spoon-tests/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-17 diff --git a/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/android-espresso-1.0-20131019.232110-1.jar b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/android-espresso-1.0-20131019.232110-1.jar new file mode 100644 index 0000000..0d5de96 Binary files /dev/null and b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/android-espresso-1.0-20131019.232110-1.jar differ diff --git a/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/android-espresso-1.0-20131019.232110-1.jar.md5 b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/android-espresso-1.0-20131019.232110-1.jar.md5 new file mode 100644 index 0000000..ab266a1 --- /dev/null +++ b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/android-espresso-1.0-20131019.232110-1.jar.md5 @@ -0,0 +1 @@ +44ad9229c39418a729fe5adfe2511e7b \ No newline at end of file diff --git a/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/android-espresso-1.0-20131019.232110-1.jar.sha1 b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/android-espresso-1.0-20131019.232110-1.jar.sha1 new file mode 100644 index 0000000..012cf2a --- /dev/null +++ b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/android-espresso-1.0-20131019.232110-1.jar.sha1 @@ -0,0 +1 @@ +2566c88b5eba4fa5c3d8577aefd3306913f38bf5 \ No newline at end of file diff --git a/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/android-espresso-1.0-20131019.232110-1.pom b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/android-espresso-1.0-20131019.232110-1.pom new file mode 100644 index 0000000..9c59b2d --- /dev/null +++ b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/android-espresso-1.0-20131019.232110-1.pom @@ -0,0 +1,8 @@ + + + 4.0.0 + com.google.android + android-espresso + 1.0-SNAPSHOT + diff --git a/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/android-espresso-1.0-20131019.232110-1.pom.md5 b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/android-espresso-1.0-20131019.232110-1.pom.md5 new file mode 100644 index 0000000..5ec67b6 --- /dev/null +++ b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/android-espresso-1.0-20131019.232110-1.pom.md5 @@ -0,0 +1 @@ +3cd9200bc6ded975ef56948ccbe82ce5 \ No newline at end of file diff --git a/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/android-espresso-1.0-20131019.232110-1.pom.sha1 b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/android-espresso-1.0-20131019.232110-1.pom.sha1 new file mode 100644 index 0000000..da1b7f5 --- /dev/null +++ b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/android-espresso-1.0-20131019.232110-1.pom.sha1 @@ -0,0 +1 @@ +ab2afc662e38c62be46082f94e86fd0b6d3b7a95 \ No newline at end of file diff --git a/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/maven-metadata.xml b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/maven-metadata.xml new file mode 100644 index 0000000..c8aa368 --- /dev/null +++ b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/maven-metadata.xml @@ -0,0 +1,25 @@ + + + com.google.android + android-espresso + 1.0-SNAPSHOT + + + 20131019.232110 + 1 + + 20131019232110 + + + jar + 1.0-20131019.232110-1 + 20131019232110 + + + pom + 1.0-20131019.232110-1 + 20131019232110 + + + + diff --git a/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/maven-metadata.xml.md5 b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/maven-metadata.xml.md5 new file mode 100644 index 0000000..1eadbef --- /dev/null +++ b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/maven-metadata.xml.md5 @@ -0,0 +1 @@ +76352da1adaa1c1ad81e7819ec9193d8 \ No newline at end of file diff --git a/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/maven-metadata.xml.sha1 b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/maven-metadata.xml.sha1 new file mode 100644 index 0000000..4091e32 --- /dev/null +++ b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/1.0-SNAPSHOT/maven-metadata.xml.sha1 @@ -0,0 +1 @@ +f5537b45afacd274c96de06d4ebf7634ed190ed5 \ No newline at end of file diff --git a/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/maven-metadata.xml b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/maven-metadata.xml new file mode 100644 index 0000000..9f9ec6e --- /dev/null +++ b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/maven-metadata.xml @@ -0,0 +1,11 @@ + + + com.google.android + android-espresso + + + 1.0-SNAPSHOT + + 20131019232110 + + diff --git a/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/maven-metadata.xml.md5 b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/maven-metadata.xml.md5 new file mode 100644 index 0000000..8ac3c5b --- /dev/null +++ b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/maven-metadata.xml.md5 @@ -0,0 +1 @@ +959e5a9e225f28380ceb1318244cc180 \ No newline at end of file diff --git a/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/maven-metadata.xml.sha1 b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/maven-metadata.xml.sha1 new file mode 100644 index 0000000..38565b0 --- /dev/null +++ b/android-sample-espresso-spoon-tests/repo/com/google/android/android-espresso/maven-metadata.xml.sha1 @@ -0,0 +1 @@ +bc65a7fb4ba92351c17475733cdb45b95d8cc4e2 \ No newline at end of file diff --git a/android-sample-espresso-spoon-tests/src/main/java/com/octo/android/sample/espressospoon/test/EspressoSampleTest.java b/android-sample-espresso-spoon-tests/src/main/java/com/octo/android/sample/espressospoon/test/EspressoSampleTest.java new file mode 100644 index 0000000..333b282 --- /dev/null +++ b/android-sample-espresso-spoon-tests/src/main/java/com/octo/android/sample/espressospoon/test/EspressoSampleTest.java @@ -0,0 +1,44 @@ +package com.octo.android.sample.espressospoon.test; + +import android.test.ActivityInstrumentationTestCase2; + +import com.octo.android.sample.R; +import com.octo.android.sample.ui.HelloAndroidActivity; +import com.squareup.spoon.Spoon; + +import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView; +import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.click; +import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.matches; +import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId; +import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText; + +public class EspressoSampleTest extends ActivityInstrumentationTestCase2 { + + public EspressoSampleTest() { + super(HelloAndroidActivity.class); + } + + @Override + public void setUp() throws Exception { + super.setUp(); + getActivity(); + } + + public void testCompute() throws Exception { + onView(withId(R.id.button_main)).check(matches(withText("Click !"))); + // given + Spoon.screenshot(getActivity(), "initial_state"); + + // when + onView(withId(R.id.button_main)).perform(click()); + + // then + Spoon.screenshot(getActivity(), "button_clicked"); + onView(withId(R.id.textview_hello)).check(matches(withText("42"))); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + } +} diff --git a/pom.xml b/pom.xml index 074db09..1aecfb7 100644 --- a/pom.xml +++ b/pom.xml @@ -383,6 +383,7 @@ android-sample-tests android-sample-ui-tests android-sample-espresso-tests + android-sample-espresso-spoon-tests @@ -464,6 +465,12 @@ android-sample-tests + + espresso-spoon + + android-sample-espresso-spoon-tests + + jacoco