Introducing
Your new presentation assistant.
Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.
Trending searches
Senior Developer Consultant
Last week:
This week:
Next time on
Android Bootcamp:
Layout and Design
Focus
Structure
Quality
Freedom
Communication
SLOW
1. Write a second functional test to express this new behaviour:
Espresso
Given I have opened the App
When I enter my name
And click on OK
Then the main activity should open,
And show a welcome message that includes my name.
Given I have entered my name,
When I open the menu
Then it should have an option 'Treasure List'
And When I click on that option
Then I should see a heading on the page saying 'Find these Treasures:'
View layer - Instrument Tests
1. Download Espresso bundled jar from
https://code.google.com/p/android-test-kit/source/browse/bin/espresso-standalone/espresso-1.1-SNAPSHOT-bundled.jar
Save it in src/androidTest/libs
2. Change build.gradle dependencies:
dependencies {
compile 'com.android.support:appcompat-v7:+'
androidTestCompile fileTree(dir: 'src/androidTest/libs', includes: ['*.jar'])
}
3. Resync Android Studio with
Tools > Android > Sync Project With Gradle Files
4. Now write the test method (JUnit 3 style only is supported)
Try this:
Espresso.onView(ViewMatchers.withId(R.id.player_field)).perform(ViewActions.typeText("Fred"));
Then static import the methods for better readability.
5. Complete the test shown earlier
6. Start up the emulator and check that it runs and passes.
FAST
Robolectric
2. Make the test compile.
3. Run the test and watch it fail (hopefully for the right reason!)
4. Optional: Write similar tests for 'High Scores' and 'Map' menu options
Controller
layer
FEST Android augments Hamcrest matchers with a fluent interface tailored for Android
JUnit
Do Androids Dream of Electric Sheep?
Philip K Dick's 1968 sci-fi classic that inspired Blade Runner
1. Create src/androidTest/java (exact names are important)
2. Right click to create a new package com.thoughtworks.androidbootcamp.test (name MUST be same as base package name plus .test)
3. Right click to create a new Java class in this package. Extend this class from ActivityInstrumentationTestCase2<HelloAndroid>
4. Create a no-arg constructor that calls super with package name and HelloAndroid.class (suppress the deprecated warning)
5. Start the Genymotion emulator
6. Now should be able to run from Android Studio (right click on the test file) or from command line with gradle connectedCheck
7. To ensure the test is running correctly, make it fail by adding
fail();
Model
layer
1. Modify the onCreateVIew event of the PlaceholderFragment so that it calls either showTreasureList, showHighScores or showMap, depending on which section number is passed in.
2. Implement the three methods to set the text of the section label to the heading for the page.
3. Run the tests. If all is well they should pass!
1. Go to Novoda's Gradle Android Test Plugin from
https://github.com/novoda/gradle-android-test-plugin
2. Add a new module to your Android project to contain the unit tests
3. Create a JUnit test to test the Game class (just test the player name for now - this test should pass)
4. Write a Robolectric test to test three new methods of the HelloAndroid controller - showTreasureList, showMap and showHighScores.
5. Run the tests so you can see them fail.
Use gradle check --info on the command line from the AndroidBootcampProject directory. Results are reported at AndroidBootcampProject/AndroidBootcampTest/build/test-report/index.html
6. Optional: Persuade Android Studio to run the tests. This is, unfortunately, not easy. Step by step instructions are at the Android Bootcamp Github.
design by Dóri Sirály for Prezi
The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.