Test Driven Tutorial (Android)

I didn’t like any of the android tutorials I found online, so I’m making my own. At the moment the actual programming part still hasn’t been tested, so I can’t suggest you quit school and use this instead, but if you would like to be the first guinea pig please have at.

  1. Install Android Studio.  If you do not already have JDK (the Java Development Kit, a set of tools necessary for working in Java, which you’ll be doing) installed, it will prompt you to do so.  Pay careful attention to the tiny type telling you which version of the JDK to install.
  2. Import the project.  If you know how to import from github, you can find the most up to date code here.  If you don’t know what that means, download the zip from dropbox.  You will be given a lot of choices, just use the defaults.  If you succeed it will look like.
  3. Create an emulator.  This will create an image of an android device on your pc for easy testing.  Technically you could just transfer the file to your phone every time, but I assure you you don’t want to.
    1. Click into the android virtual device manager (Tools/android/AVD Manager).
    2. Click “Create new device”
    3. select “nexus 6”, click next
    4. select “lollipop, x86”, click next
    5. click “show advanced settings”, scroll to the bottom, unclick “enable keyboard input”.  This will force the image to simulate a software keyboard, rather than use your physical keyboard
    6. click finish
    7. Launch app on emulator
  4. Launch App on emulator
    1. click play button in button bar or select Run/Run App
    2. Wait a bit.
    3. Faux phone screen appears on your PC.  Unlock and it’s running your app
  5. Run your first tests
    1. in the tree on the left, click into app/java/com.acesounderglass.testdriventutorial(androidTest)/ActivityTest
    2. Right click on the file and select [Run ‘ActivityTest’].  The tests should run and pass.
    3. Open up the file.  You’ll see several functions starting with testX, some of which are commented out.  Only the uncommented ones are currently running
    4. Uncomment the first commented out test, code only, not the description (you can tell because the // starts at col 1, not  5).  Run tests again, the new test will fail.
    5. The goal is for you to figure out how to get that test (and the subsequent ones) passing without further instruction from me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: