Examples of de-mocking test code as presented on Droidcon Berlin 2022.
Here is the top 5 articles on KotlinTesting in 2022.
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.
Mockito cannot mock/spy because your class is final class? We can fix that.
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.
Welcome to first 2022 issue of JVM Testing!I this edition I decided to put Compose and KMM related content into separate sections.
JVM and Kotlin testing libraries - Gradle dependencies and latest versions.
Welcome to November issue of JVM Testing Monthly. This month you will find selection of Kotlin content! Keep learning and get better at unit testing everyday.
Welcome to October issue of JVM Testing Monthly! This month you will find curated list blogposts and articles about testing techniques, recordings from SpringOne conference and Android specific content! Keep learning and get better at unit testing everyday.
Learn how to create custom Timber Tree to test log outputs in unit tests. Mocking Timber, unit testing logs.
Welcome to September issue of JVM Testing Monthly! This month you will find curated list blogposts and articles about testing techniques, effective usage of Kotlin and some Android goodies. Keep learning and get better at unit testing everyday.
What's new in JVM testing? Check July 2021 issue.
Do you want to assert that SLF4J actually logged warn with proper message? Check this guide on how to mock logger in tests, in Kotlin and Java.
What's new in JVM testing? Check June 2021 issue.
Strikt is assertion library built for Kotlin with API which allows building multi assertions and gives us readable assertion errors.
What's new in JVM testing? Check May 2021 issue.
Writing tests involves repeating some patterns over and over again. IntelliJ IDEA can shorten the process of test creation with the help of live templates.
Check two approaches to test kotlin coroutines code depending on time.
IntelliJ is great tool for developer productivity. Check how can we adjust IDE to our preferences. Tutorial: how to create custom live template?
The story of debugging date time formatting issue. It passes locally, it fails on CI. How can it be?
KotlinTesting.com now has stories!
Nested tests in Junit5 allows us grouping test cases. Check how to do this in presenter tests.
Frequently Asked Questions - now I'm giving answers about things you've asked me on 2020 conferences.
How to easily stub or mock suspend function in Kotlin? MockK is the solution. See MockK examples for mocking coroutines.
Functional tests in Ktor - how to mock application server with TestApplicationEngine?
Refactoring Java Mockito based test suite to Mockito-Kotlin DSL
How to test Retrofit calls? Example of testing requests executed with Retrofit and OkHttp.
Story of an attempt to test the code generated by DataBinding library.
Testing time based properties with Joda Time - hints how to write micro DSL included!
Creating parameterized tests in Kotlin: data driven testing, collection inspections and generating test cases with FreeSpec.
Exceptions are crucial part of some Java APIs. How to assert that exceptions was thrown? In this note you will examples of various exception assertion techniques.
When the test passes, when it fails and why it crashes? In this short note we will try to find the answers for those questions.
It's usually in our best interest to keep one assertion per test method. Yet, situation when more than one check in single test method is present may occur.
Using Spek to generate test cases
In his example we will try to implement VenueDetailsViewModel in TDD style. TDD (Test Driven Development) is development technique, where developer relies on unit tests created before actual implementation.
This repository contains examples of basic unit tests written in Kotlin. In specific directories you can find gradle buildscript with needed dependencies and configuration, simple unit test and parameterized test.