Developer: “YESSS! My world-class widget test is ready to run.”
(runs the test)
Debug Console: “Expected to see 1 widget, found none.”
Developer: What! Why, why, why!!!
(figures out all async calls in the widget; spends 4 hours re-reading about widget testing, exploring the source code of
WidgetTester.pump() and setting up mock classes using Mockito.)
Developer: “Muwaha haha! I am the greatest mocker ever lived.”
(runs the test again)
Debug Console: “A RenderFlex overflowed by 20 pixels on the right.”
IntelliJ IDEA is a free and open-source (yay!) IDE for Java development. It’s a huge-huge-huge improvement over the slow and ageing Eclipse. Recently, I wanted to do some programming practice, so I thought why not in Java. I started by writing my code in good ol’ Notepad++. Very soon I reminded myself about my TDD resolution — to never write code without unit tests. This meant needing something serious to write my Java code. It was a good opportunity to try out IDEA, something I had been meaning to do since I learnt that Android Studio is based on it (that was long ago, like 3-4 years ago).
Creating a Java project and running/debugging code in IDEA is pretty simple and quick. Configuring IDEA to support JUnit 5 tests, on the other hand, is no child’s play. It took my literally more than a day to get it to work. And hence this blog post, which is a note to self to quickly set up things in future.
If you are interested in checking the Java project that I had created in IDEA (referred to in my screenshots below), check my GitHub repo.
Continue reading Creating a Java 10 project in IntelliJ IDEA with JUnit 5 and Gradle support