I am creating a library that will process information in accordance with the user's default settings and save it to SharedPreferences, which can be changed by the developer in their application before initializing my library.
The SDK should only be initialized once per application instance, otherwise a RuntimeError will be fired. So on the application side in the Application class should be something like this:
public class SampleApplication extends Application { @Override public void onCreate() { super.onCreate();
Abstract sdk implementation:
public class Sdk { private static SampleApplication sInstance; private void Sdk(){ } public static SampleApplication getInstance() throws RuntimeException { if (sInstance == null) { throw new RuntimeException(); } return sInstance; } public static void initialize() { if (sInstance == null) { sInstance = new Sdk();
The problem occurs when I want to test several scripts to call this method (which can only be called once per application instance).
So, I created an Android test that extends ApplicationTest
ApplicationTest:
public class ApplicationTest extends ApplicationTestCase<SampleApplication> { public ApplicationTest() { super(SampleApplication.class); } }
Test for Android:
public class SampleTest extends ApplicationTest { @Override protected void setUp() throws Exception {
I tried to finish and create the application again, but without success. My question is: can I restart the Android test application? Am I something wrong here?
iGoDa source share