2016-07-06 3 views
1

Я создал простой junit-тест для своего приложения, используя инструмент Robolectric.Robolectric дает исключение

import org.junit.Before; 
import org.junit.Test; 
import org.junit.runner.RunWith; 
import org.robolectric.Robolectric; 
import org.robolectric.RobolectricGradleTestRunner; 
import org.robolectric.annotation.Config; 

import static org.junit.Assert.assertNotNull; 

@RunWith(RobolectricGradleTestRunner.class) 
@Config(constants = BuildConfig.class,sdk = 21) 
public class MainActivityTest { 
    MainActivity activity; 
    @Before 
    public void setUp(){ 
     activity= Robolectric.setupActivity(MainActivity.class); 
    } 

    @Test 
    public void shouldNotBeNull(){ 
    assertNotNull(activity); 
    } 
} 

В принципе, этот тест должен пройти, поскольку деятельность не является нулевой. Однако я получаю это странное исключение.

java.lang.IllegalArgumentException: path must be convex 

at android.graphics.Outline.setConvexPath(Outline.java:216) 
at android.graphics.drawable.GradientDrawable.getOutline(GradientDrawable.java:1441) 
at android.view.ViewOutlineProvider$1.getOutline(ViewOutlineProvider.java:38) 
at android.view.View.rebuildOutline(View.java:11116) 
at android.view.View.onAttachedToWindow(View.java:12960) 
at android.view.ViewGroup.onAttachedToWindow(ViewGroup.java:3815) 
at android.view.View.dispatchAttachedToWindow(View.java:13406) 
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2707) 
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2714) 
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2714) 
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2714) 
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2714) 
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2714) 
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2714) 
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1292) 
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054) 
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at org.robolectric.shadows.ShadowMessageQueue.dispatchMessage(ShadowMessageQueue.java:130) 
at org.robolectric.shadows.ShadowMessageQueue.access$100(ShadowMessageQueue.java:30) 
at org.robolectric.shadows.ShadowMessageQueue$1.run(ShadowMessageQueue.java:95) 
at org.robolectric.util.Scheduler$ScheduledRunnable.run(Scheduler.java:269) 
at org.robolectric.util.Scheduler.runOneTask(Scheduler.java:179) 
at org.robolectric.util.Scheduler.advanceTo(Scheduler.java:160) 
at org.robolectric.util.Scheduler.advanceBy(Scheduler.java:143) 
at org.robolectric.util.Scheduler.unPause(Scheduler.java:54) 
at org.robolectric.shadows.ShadowLooper.unPause(ShadowLooper.java:266) 
at org.robolectric.shadows.ShadowLooper.runPaused(ShadowLooper.java:306) 
at org.robolectric.shadows.CoreShadowsAdapter$2.runPaused(CoreShadowsAdapter.java:45) 
at org.robolectric.util.ActivityController.visible(ActivityController.java:173) 
at org.robolectric.util.ActivityController.setup(ActivityController.java:210) 
at org.robolectric.Robolectric.setupActivity(Robolectric.java:46) 
at team.football.ael.MainActivityTest.shouldNotBeNull(MainActivityTest.java:24) 
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) 
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) 
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) 
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:251) 
at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:188) 
at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:54) 
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) 
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) 
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) 
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) 
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:152) 
at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 
at org.junit.runner.JUnitCore.run(JUnitCore.java:137) 
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) 
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234) 
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74) 
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) 

Любые идеи о том, что происходит?

Thanks,

Theo.

+0

См. Https://github.com/robolectric/robolectric/issues/1810, какую версию вы используете? – splatte

+0

Я использую robolectric 3.0 – Theo

+1

Обновление до 3.1 должно содержать исправление для вашей проблемы. – splatte

ответ

Смежные вопросы