lundi 8 mai 2017

Android Local Unit Test returns error with a new Intent

I'm trying to make a simple Local Unit Test on an Android method, but when I call new Intent (), it returns an error: Method threw 'java.lang.RuntimeException' exception. Cannot evaluate android.content.Intent.toString()

I tried to @mock Intent intent and also @PrepareForTest({Intent.class}), but I still get the same error...

Am I doing something wrong? Do I need anything else? Do I need to use Instrumented test for this?

Here's the code:

@RunWith(MockitoJUnitRunner.class)
@PrepareForTest({Intent.class})
public class TimeFrameManagerTest
{

@Mock
Context mMockContext;


@Before
public void setUp ()
{

}


@Test
public void alarmSchedulePosteriorTime ()
{

    Intent intent = new Intent (); //Method threw 'java.lang.RuntimeException' exception. Cannot evaluate android.content.Intent.toString()

}


}

Aucun commentaire:

Enregistrer un commentaire