robolectric

NoSuchMethodError for FragmentManager.getFragmentFactory

僤鯓⒐⒋嵵緔 提交于 2019-12-02 02:33:32
问题 I'm trying to use the new FragmentScenario APIs of the androidx testing libraries but the test fails trying to launch the fragment scenario like so: fragmentScenario = launchFragmentInContainer<MyFragment>(args) The stacktrace is: java.lang.NoSuchMethodError: androidx.fragment.app.FragmentManager.getFragmentFactory()Landroidx/fragment/app/FragmentFactory; at androidx.fragment.app.testing.FragmentScenario$1.perform(FragmentScenario.java:178) at androidx.fragment.app.testing.FragmentScenario$1

Impossible RuntimeException: Stub with Robolectric

爱⌒轻易说出口 提交于 2019-12-01 23:37:45
I've spent hours trying to figure this out. I'm using Maven to build and test a project in IntelliJ IDEA with Robolectric. I have Robolectric declared before Android in the POM, and I've used the SDK deployer to install to my local repo. But I still keep getting this error: java.lang.RuntimeException: Stub! at android.net.Uri.$$robo$$Uri_30fc_parse(Uri.java:53) at org.robolectric.bytecode.ShadowWrangler$InvocationPlan.callOriginal(ShadowWrangler.java:591) at android.net.Uri.parse(Uri.java) at org.robolectric.shadows.ShadowMediaStore.reset(ShadowMediaStore.java:27) at org.robolectric

Manifest and setup issues getting Robolectric working with Android Studio 1.1.0

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 17:11:41
I am trying to get Robolectric tests up and working in our current project, and not having a lot of luck. My preference would be to get these to run within Android Studio 1.1.0+. This is my project structure: and here is my test: import android.widget.Button; import com.mycompany.android.app.R; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.Robolectric; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import static org.junit.Assert.assertNotNull; @Config(manifest = "AndroidManifest.xml") @RunWith

Robolectric: IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity

筅森魡賤 提交于 2019-12-01 15:02:21
I'm new to Robolectric and instrumentation testing in general on Android. I followed along the guide for Robolectric for testing my first test. However I'm getting: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. I searched for the error, but no solution is helping. I'm including everything that could cause this error. Gradle: apply plugin: 'com.android.application' apply plugin: 'com.neenbedankt.android-apt' //needed for source code generation apply plugin: 'jacoco' apply plugin: 'de.mobilej.unmock' android { compileSdkVersion 22

Robolectric: IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity

半世苍凉 提交于 2019-12-01 13:54:08
问题 I'm new to Robolectric and instrumentation testing in general on Android. I followed along the guide for Robolectric for testing my first test. However I'm getting: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. I searched for the error, but no solution is helping. I'm including everything that could cause this error. Gradle: apply plugin: 'com.android.application' apply plugin: 'com.neenbedankt.android-apt' //needed for source

How to run unit tests with dependency to an Android library module?

坚强是说给别人听的谎言 提交于 2019-12-01 11:25:40
Whenever I try to run unit-tests for classes in my app module that depend on classes from an library module, I get this: java.lang.NoClassDefFoundError: de/ivu/junittest/DummyData at de.ivu.junittest.app.DummyModel.<init>(DummyModel.java:16) at DummyModelTest.testInstantiation(DummyModelTest.java:7) ... In the above sample, DummyData is part of the lib module, while DummyModel is part of the app module. DummyModel has a member of type DummyData , but instantiating this in the test-class DummyModelTest causes the aforementioned exception at test-time. The project structure is as follows:

JUnit testing on class with firebase

為{幸葍}努か 提交于 2019-12-01 10:52:23
I'm trying to JUnit test this class: public class WeekListActivity extends AppCompatActivity implements AdapterView.OnItemClickListener { private ArrayList<String> weekList = new ArrayList<>(); private ArrayAdapter<String> adapter; ListView weekListView; Button AddWeekButton; EditText InsertWeekEditText; String weekNumber; String subjectName; String subjectCode; User user; DatabaseReference mDatabase; DatabaseReference mRef; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_week_list); FirebaseApp.initializeApp

Testing with SugarORM and Robolectric

↘锁芯ラ 提交于 2019-12-01 09:24:59
I trying to setup an testing environment for my android project. The basic Robolectric setup is done. I used this nice tutorial . If I comment out SugarORM in my Manifest.xml, all test works fine. But If I want to use it with SugarORM I always get this error: java.lang.NullPointerException at dalvik.system.DexFile$DFEnum.hasMoreElements(DexFile.java:239) at com.orm.SugarDb.getDomainClasses(SugarDb.java:37) at com.orm.SugarDb.createDatabase(SugarDb.java:104) at com.orm.SugarDb.onCreate(SugarDb.java:100) at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:252) at

JUnit testing on class with firebase

主宰稳场 提交于 2019-12-01 09:21:13
问题 I'm trying to JUnit test this class: public class WeekListActivity extends AppCompatActivity implements AdapterView.OnItemClickListener { private ArrayList<String> weekList = new ArrayList<>(); private ArrayAdapter<String> adapter; ListView weekListView; Button AddWeekButton; EditText InsertWeekEditText; String weekNumber; String subjectName; String subjectCode; User user; DatabaseReference mDatabase; DatabaseReference mRef; @Override protected void onCreate(Bundle savedInstanceState) { super

Robolectric accessing database throws an error

你。 提交于 2019-12-01 07:20:34
I have a test that creates an activity which attempts to get some data from the database. This fails with SQLiteException 17:40:40.528 [DEBUG] [TestEventLogger] android.database.sqlite.SQLiteException: Cannot open SQLite connection, base error code: 14 17:40:40.528 [DEBUG] [TestEventLogger] at org.robolectric.shadows.ShadowSQLiteConnection.rethrow(ShadowSQLiteConnection.java:53) 17:40:40.528 [DEBUG] [TestEventLogger] at org.robolectric.shadows.ShadowSQLiteConnection.access$600(ShadowSQLiteConnection.java:30) 17:40:40.529 [DEBUG] [TestEventLogger] at org.robolectric.shadows