One of my classes uses SpannableStringBuilder and I need to write unit test code for it. This class is for general use and does not interact with any UI components. I considered it as a local unit test but Android Studio complains that 'unit test not mocked'. I've checked Android Mock and robolectric but I can't figure out which instrumentation I have to mock. I also tried putting the test under the AndroidTest directory and ran it as an instrumentation test but still got an error 'Class not found: "....." Empty test suit'.
The unit test code:
package xxxxxxx; // Sorry but I should keep it secret now.
import android.support.test.filters.SdkSuppress;
import android.test.suitebuilder.annotation.SmallTest;
import android.text.SpannableString;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import xxxxxxx.HtmlParser;
import static org.junit.Assert.*;
@RunWith(AndroidJUnit4.class)
@SdkSuppress(minSdkVersion=16)
@SmallTest
public class HtmlParserTest {
@Test
public void TestGetHtml() {
// assertion goes here
}
@Test
public void TestGetPlainText() {
// assertion goes here
}
}
Aucun commentaire:
Enregistrer un commentaire