I just can’t remember how to use the robolectric r...
# minutest
d
I just can’t remember how to use the robolectric runner and I’m lazy, was hoping you could remind me about the annotations etc
d
Oh, I guess my own example won't speak any better than this: https://developer.android.com/training/testing/set-up-project Thanks for wanting to check this... 🙂
d
Ah, I think I remember why I didn’t bite the Minutest bullet in that entire blog post series!
Copy code
@RunWith(AndroidJUnit4::class)
Copy code
@RunWith(MinutestJUnit4Runner::class)
abstract class JUnit4Minutests
So there are 2 test runners declared if you say
Copy code
@RunWith(AndroidJUnit4::class)
class MyTests : JUnit4Minutests()
MinutestJUnit4Runner synthesises the tests from the rootContext, but AndroidJUnit4 won’t have run it to do that. Unfortunately a runner is the only way in JUnit 4 to make new tests. I think that AndroidJUnit4 could be a Rule, but it isn’t, I suppose because it goes on to use rules to implement other features and it would just have been hard.
I had worked on the principle that Google would have gotten JUnit 5 support nailed.
What I’ve done with Spring is delegate to the recalcitrant runner code from a context builder
🤔 1
d
Thanks again for looking into this! Now it makes sense... I just don't really understand that last comment...?
d
Sorry, overly pretentious! Test runners generally hack the test lifecycle (bringing up environments before tests run for eg). In minutest we can do that with a context builder extension method, and so for Spring I wrote a springFixture clause that delegated to the code that the Spring test runner was invoking