Uncategorized
Stubbing with doAnswer vs doReturn – what’s the difference?
Most of the times while stubbing with Mockito or MockK you will use doReturn construction. But do you know, that you can stub your test double method in other way – with doAnswer. Let’s take a look a both stubbing types.
How to mock final classes in Kotlin with Mockito?
Let’s consider the following system under test: And following test method: if you are unsure how to use Mockito with Kotlin, check https://kotlintesting.com/using-mockito-in-kotlin-projects/ After running this test it is likely that you will encounter the following error: Classes marked as „final” should not be extended Kotlin default modifier translates to „final” in Java Classes in …
How to mock final classes in Kotlin with Mockito? Read More »
How to use jUnit4 & jUnit5 in one project?
When you have existing test suite containing jUni4 tests and you want to migrate slowly to jUnit5 to make use of new APIs and modern test engine, you may encounter some issues – not all tests will be visible in reports.
Libraries for Kotlin & JVM Testing
JVM and Kotlin testing libraries – Gradle dependencies and latest versions.
JVM Testing Newsletter | November 2021
Articles & blogposts Ktor in memory DB Testing Part of series: building a backend with Ktor. In this article Marco focuses on configuring database implementation for test suite. How to use an in-memory database for testing on Ktor SERIES: Building a backend with Ktor Part 1: Structuring a Ktor project Part 2: How to persist …
JVM Testing Newsletter | October 2021
Articles & blogposts Mocking Matchers API Story about the interesting behavior of mocking library and the difficulties of defining API surface for a library. Mocking Matchers API Diving into Matchers API of various mocking libraries such as Mockito, mockito-kotlin, mockk Krossovochkin Testing Hybrid Jetpack Compose Apps Guide to testing Jetpack Compose on Android using androidx …
Don’t mock static: test Timber Logger with trees
Learn how to create custom Timber Tree to test log outputs in unit tests. Mocking Timber, unit testing logs.
JVM Testing Newsletter | September 2021
Articles & blogposts Let’s code: graphs in java Step-by-step TDD implementation of graphs in plain Java. Let’s code: graphs in java I have been obsessed with graphs for a few years now. This obsession has resulted in three projects:… DEV CommunityJohn Mercier 5 Reasons Why You Should Never, Ever Write Tests Clickbait? Maybe a little. …
JVM Testing Newsletter | July 2021
Articles & blogposts Hidden Perks of Unit Tests Hidden Perks of Unit Tests Unit testing is one of my favorite software engineering techniques. In our industry, the word “testing” is strongly associated with the word “bug”, so the common belief is that unit tests help find/eradicate/prevent bugs. And while this is not untrue, there’s much …