https://github.com/mttkay/calculon
A testing DSL for Android views and activities
https://github.com/mttkay/calculon
Last synced: 9 months ago
JSON representation
A testing DSL for Android views and activities
- Host: GitHub
- URL: https://github.com/mttkay/calculon
- Owner: mttkay
- Created: 2010-01-08T23:36:08.000Z (almost 16 years ago)
- Default Branch: master
- Last Pushed: 2013-09-18T17:45:59.000Z (about 12 years ago)
- Last Synced: 2025-03-16T00:11:23.542Z (9 months ago)
- Language: Java
- Homepage:
- Size: 252 KB
- Stars: 148
- Watchers: 5
- Forks: 20
- Open Issues: 2
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
- awesome-android-testing - calculon
README

## "Calculon never does two takes!"
Calculon is a testing DSL for Google Android. It allows you to write activity tests and user story tests using cool stuff like this:
public class FooTest extends CalculonStoryTest {
public FooTest() {
super("com.example", FooActivity.class);
}
public void testFooAndBarStuff() {
// direct assertion on current activity
assertThat().inPortraitMode();
assertThat().viewExists(R.id.launch_bar_button);
// assert specific condition on current activity
assertThat().satisfies(new Predicate() {
public boolean check(Activity target) {
return target.isTaskRoot();
}
});
// a view assertion that performs an activity check
Activity barActivity = assertThat(R.id.launch_bar_button).click().starts(BarActivity.class);
// other activity objects are also testable
assertThat(barActivity).inLandscapeMode();
// a direct view assertion
assertThat(R.id.button_2).isVisible();
// a view assertion that performs a check on another view
assertThat(R.id.button_2).click().implies(R.id.launch_bar_button).isGone();
// assert a specific condition on another view
assertThat(R.id.button_2).click().implies(R.id.launch_bar_button).satisfies(
new Predicate() {
public boolean check(View view) {
return view.getVisibility() == View.GONE;
}
});
// a key event assertion on an activity
assertThat(barActivity).keyDown(KeyEvent.KEYCODE_X).finishesActivity();
}
}