<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://devlicio.us/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Tuna Toksoz : android</title><link>http://devlicio.us/blogs/tuna_toksoz/archive/tags/android/default.aspx</link><description>Tags: android</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><item><title>Testing on Android</title><link>http://devlicio.us/blogs/tuna_toksoz/archive/2010/01/06/testing-on-android.aspx</link><pubDate>Wed, 06 Jan 2010 00:30:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:54931</guid><dc:creator>Tuna Toksoz</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/tuna_toksoz/rsscomments.aspx?PostID=54931</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/tuna_toksoz/commentapi.aspx?PostID=54931</wfw:comment><comments>http://devlicio.us/blogs/tuna_toksoz/archive/2010/01/06/testing-on-android.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/tuna_5F00_toksoz/android_5F00_15CDAE53.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;margin-left:0px;border-left-width:0px;margin-right:0px;" title="android" border="0" alt="android" align="right" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/tuna_5F00_toksoz/android_5F00_thumb_5F00_3099D45F.png" width="210" height="240" /&gt;&lt;/a&gt;For the last couple of months, I have been working on Android platform as part of Software Engineering course(more on that later, i hope). Even though there are a lot of things I don’t like about android (like XML layouts and the ids of widgets being held in some other class etc but perhaps this is just me), I overall find it a good platform to work with.&lt;/p&gt;  &lt;p&gt;What I really liked in Android is that it provides an Out-of-the-box environment for easy testing android applications. I don’t know how Windows Mobile projects handle this situation, but what android does is that it executes the test in the context of virtual machine. Android integrates nicely with &lt;a href="http://www.junit.org/"&gt;JUnit&lt;/a&gt; framework, which is the java brother of &lt;a href="http://nunit.org"&gt;NUnit&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;What is more interesting than this is that Android also has UI testing framework. Being a person who hasn’t written UI tests much (as in none), I can’t say if it is a good one or not. I just liked the feature that came out of the box. &lt;/p&gt;  &lt;p&gt;I have created a simple Activity (you can think of it as a window, but not exactly)&lt;/p&gt;  &lt;pre class="java" name="code"&gt;
public class SampleActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        final Button b=(Button)findViewById(R.id.Button01);
        final EditText t=(EditText)findViewById(R.id.EditText01);
        b.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				// TODO Auto-generated method stub
				t.setText(t.getText().toString()+&amp;quot;hello&amp;quot;);
			}
		});
    }
}&lt;/pre&gt;

&lt;p&gt;And created the following test. &lt;/p&gt;

&lt;pre class="java" name="code"&gt;
public class SampleActivityInstrumentation extends
		android.test.ActivityInstrumentationTestCase2 {

	public SampleActivityInstrumentation() {
		super(&amp;quot;com.myandroid&amp;quot;, SampleActivity.class);
		// TODO Auto-generated constructor stub
	}

	public void test_OK_button_appends_hello() throws Throwable {
		SampleActivity tne = (SampleActivity) getActivity();

		final Button btn=(Button) tne.findViewById(com.myandroid.R.id.Button01);
		final EditText titleEdit = (EditText) tne.findViewById(com.myandroid.R.id.EditText01);
		runTestOnUiThread(new Runnable() {
			public void run() {
				titleEdit.performClick();
			}
		});
		sendKeys(&amp;quot;H E L L O&amp;quot;);
		runTestOnUiThread(new Runnable() {
			public void run() {
				btn.performClick();
			}
		});
		assertEquals(&amp;quot;hellohello&amp;quot;,titleEdit.getText().toString());
		
	}

}&lt;/pre&gt;

&lt;p&gt;I found it very cool to have such a nice integration. More than that is that they use proven testing framework out of the box. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=54931" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/tuna_toksoz/archive/tags/ui/default.aspx">ui</category><category domain="http://devlicio.us/blogs/tuna_toksoz/archive/tags/android/default.aspx">android</category><category domain="http://devlicio.us/blogs/tuna_toksoz/archive/tags/testing/default.aspx">testing</category></item></channel></rss>