1 package de.example.exampletdd.test;
3 import android.content.Intent;
4 import android.test.ActivityUnitTestCase;
5 import android.widget.Button;
6 import de.example.exampletdd.WeatherInformationActivity;
8 public class WeatherInformationActivityUnitTest extends
9 ActivityUnitTestCase<WeatherInformationActivity> {
11 private WeatherInformationActivity activity;
13 public WeatherInformationActivityUnitTest() {
14 super(WeatherInformationActivity.class);
18 protected void setUp() throws Exception {
20 final Intent intent = new Intent(this.getInstrumentation().getTargetContext(),
21 WeatherInformationActivity.class);
22 this.startActivity(intent, null, null);
23 this.activity = this.getActivity();
26 public void testIntentTriggerViaOnClick() {
27 final int buttonweather = de.example.exampletdd.R.id.buttonweather;
28 final Button view = (Button) this.activity.findViewById(buttonweather);
29 assertNotNull("Button Weather not allowed to be null", view);
33 // TouchUtils cannot be used, only allowed in
34 // InstrumentationTestCase or ActivityInstrumentationTestCase2
36 // Check the intent which was started
37 final Intent triggeredIntent = this.getStartedActivityIntent();
38 assertNotNull("Intent was null", triggeredIntent);
39 final String data = triggeredIntent.getDataString();
41 assertEquals("Incorrect data passed via the intent",
42 "http://gumartinm.name", data);