No test were found

守給你的承諾、 提交于 2021-01-27 18:40:31

问题


I am writing unit tests. I am extending the unit tests classes from ActivityInstrumentationTestCase2. I was running tests finely. But I don't know what happened. Now when I am running unit test are not running and it throws following exception

`No tests were found`

Please Help.

Here is my unit test class

public class UnitTest extends ActivityInstrumentationTestCase2<TREResults> {
    TREResults trainingReinforcementResults;

    public UnitTest(Class<TREResults>activityClass) {
        super(activityClass);
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        trainingReinforcementResults= getActivity();
    }
    public void testDownLoadTRESetting(){
    String userId = trainingReinforcementResults.getUS_USER_ID();
    Realm realm = 
    RealmSaveRestoreHelper.initRealm(trainingReinforcementResults);
    TRESettingsModelTest treSettings = 
    realm.where(TRESettingsModelTest.class).contains("userId", 
    userId).findFirst();`
    realm.beginTransaction();
    treSettings = realm.createObject(TRESettingsModelTest.class);
    treSettings.userId = userId;
    realm.commitTransaction();


}
    @Override
    protected void tearDown() throws Exception {
        super.tearDown();
    }

回答1:


Are you using JUnit3? Whysetup() and tearDown() methods are protected? Shouldn't they be public?



来源:https://stackoverflow.com/questions/43633432/no-test-were-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!