GoogleAnalytics 1.4.2を使用している Android アプリケーションに対して Robolectric 1.1 を試しているところです。
GoogleAnalyticsTracker trackPageView Robolectrics ShadowSQLiteDatabase クラスへの呼び出しごとに例外がスローされる
java.lang.IllegalStateException: transaction already successfully
at com.xtremelabs.robolectric.shadows.ShadowSQLiteDatabase.setTransactionSuccessful(ShadowSQLiteDatabase.java:291)
at android.database.sqlite.SQLiteDatabase.setTransactionSuccessful(SQLiteDatabase.java)
at com.google.android.apps.analytics.PersistentHitStore.putEvent(Unknown Source)
at com.google.android.apps.analytics.GoogleAnalyticsTracker.createEvent(Unknown Source)
at com.google.android.apps.analytics.GoogleAnalyticsTracker.trackPageView(Unknown Source)
at uk.co.bmc.rad.util.Analytics.trackPageView(Analytics.java:78)
at uk.co.bmc.rad.ui.FindCragActivity.onCreate(FindCragActivity.java:95)
at uk.co.bmc.rad.roboelectric.activities.FindCragActivityTests.setUp(FindCragActivityTests.java:36)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at com.xtremelabs.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:292)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
アプリケーションは正常に動作し、GoogleAnalyticsTracker への呼び出しをコメント アウトすると、テストも正常に実行されます。
セットアップに何かが欠けているのでしょうか、それとも...