![]() ![]() Definitely not as exact as we want in our tests, but really useful for getting things working. This will return my “result” intent to every intent outside the app. For example, figuring out which package it was in was a PITA, so to get thing working I used this handy catchall: intending(not(isInternal())).respondWith(result) ![]() I had no idea what I was doing, so basically everything was broken, so I started by being really general and then getting more specific once I had it all working together. But in practise I return to them again and again when I’m debugging.įirst up I got my gallery test working. If they’re useless, then who cares, you’ll never think about them again. ![]() I always include really straightforward tests. I think sometimes it seems like it’s not worth having tests like this because all of this will be covered elsewhere. I have a very straightforward test that just checks that things have loaded, and it’s one I kept coming back to in order to see how things work. Having an intent rule is a little bit of magic. I was launching the intent in my test, and also calling Intents.init(). This took me a little while to make sense of, mainly because I kept getting this error saying that something had been initialised twice. The answer is the IntentsTestRule, which extends ActivityTestRule (if you’ve written a test for an activity, you’ve probably seen this). All of these launch intents, but the camera and gallery buttons launch intents that are expected to return something – an image – either from the camera or the gallery.įirst up: how the hell do you test an intent? I started with my straightforward Dagger/Mockito setup, but my tests were failing because they were launching things – the camera, or the gallery – which I then couldn’t get out of to continue my tests. There is a camera button, a gallery button and an inspire button. ![]() The picture above shows what am I testing: the home screen of my app. App running on emulator in Android Studio ![]()
0 Comments
Leave a Reply. |