Toggle Menu
Create a project that you want to test.
Figure 01: Creating an Android Test Project
Figure 02: Name your project
Figure 03: Select the project you want to test.
Figure 04: Select your build target.
Figure 04: Create your test class.
package com.elvenware.walking.test;
import android.test.ActivityInstrumentationTestCase2;
import com.elvenware.walking.LearningManActivity;
public class BasicTests extends ActivityInstrumentationTestCase2<LearningManActivity>
{
public BasicTests()
{
super("com.elvenware.walking", LearningManActivity.class);
}
}
Listing 1: Setting up your unit test.
package com.elvenware.walking.test;
import android.test.ActivityInstrumentationTestCase2;
import com.elvenware.walking.LearningManActivity;
public class BasicTests extends ActivityInstrumentationTestCase2
{
private LearningManActivity mActivity;
public BasicTests()
{
super("com.elvenware.walking", LearningManActivity.class);
}
@Override
protected void setUp() throws Exception
{
super.setUp();
mActivity = this.getActivity();
}
public void testText()
{
assertEquals("Eduction and learning",
(String)mActivity.getText(com.elvenware.walking.R.string.hello));
}
}
Listing 2: A complete test
Copyright © Charlie Calvert | Elvenware Home | Writing Code | Delphi | CSharp | My Books