问题
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