mardi 22 décembre 2015

How to test android abstract activity?

I have a BaseActivity which is an abstract activity and isn't registered in AndroidManifest. BaseActivity will call getPresenter in activity's lifecycle.

public abstract class BaseActivity extends AppCompatActivity{

    public abstract Presenter getPresenter;
    public abstract int getLayout();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayout());
        getPresenter().attachView(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        getPresenter().detachView();
    }
}

I use ActivityTestRule to launch the BaseActivity, but the following error is shown. java.lang.RuntimeException: Could not launch activity

How to test the getPresenter().attachView(this) and getPresenter().detachView() are called in correct activity's lifecycle?

Aucun commentaire:

Enregistrer un commentaire