Skip to content

Instantly share code, notes, and snippets.

@8th-Light-Blog
Created June 28, 2011 18:56
Show Gist options
  • Save 8th-Light-Blog/1051899 to your computer and use it in GitHub Desktop.
Save 8th-Light-Blog/1051899 to your computer and use it in GitHub Desktop.
Blog Title: Up and running with TDD on Android (Part 1)
Author: Colin Jones
Date: July 11th, 2009
$ android create project -t 1 -p tictactoe-android -a TicTacToe -k com.colinwjones
$ cd tictactoe-android
$ android list avd
$ android create avd -n ColinPhone -t 1
$ emulator -avd ColinPhone &
$ ant debug
$ adb install -r bin/TicTacToe-debug.apk
$ cd tests
$ ant debug
$ adb install -r bin/TicTacToe-debug.apk
$ adb shell am instrument -w com.colinwjones.tests/android.test.InstrumentationTestRunner
// with imports at top:
import import android.widget.Button;
/* some code
* ...
* ...
*/
// inside your test class:
public void testNewGameButtonExists() throws InterruptedException
{
Button button = (Button) getActivity().findViewById(R.id.new_button);
assertEquals("New Game", button.getText());
}
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/new_button" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment