How to refactor your code (without turning the project inside-out)
![](https://androidpro.io/wp-content/uploads/2023/06/photo-1511737207395-5b1ff1f86e54-1024x682.jpeg)
Are you stuck in a loop of having an old codebase that’s not testable, but not being able to refactor it because there’s no test coverage? This is a common challenge that many software development teams face, but there’s a way out. In this article, we’ll explore a 5-step process to break the cycle and improve […]
Idiomatic Kotlin in tests: idiomatic stubbings
![](https://androidpro.io/wp-content/uploads/2023/09/Idiomatic-Kotlin-in-Tests-.png.png)
In this article we will explore several ways of creating stubs… using Kotlin idioms.
Unit testing on Android – test pyramide
![](https://androidpro.io/wp-content/uploads/2023/09/photo-1631614182677-caa701f3e7e2-1024x676.jpeg)
Are you programming for Android and wondering how to write tests for your app? Or maybe you don’t have any tests in your project and don’t know how to live? Get to know my philosophy of creating tests for Android.
De-mock your tests: practical recipes
![](https://androidpro.io/wp-content/uploads/2023/09/democking-recipes_o.png)
Examples of de-mocking test code as presented on Droidcon Berlin 2022.
Stubbing with doAnswer vs doReturn – what’s the difference?
![](https://androidpro.io/wp-content/uploads/2023/09/returns-vs-answer_o-1024x512.jpg)
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?
![](https://androidpro.io/wp-content/uploads/2023/09/mockito-kotlin-final.png)
Mockito cannot mock/spy because your class is final class? We can fix that.
How to use jUnit4 & jUnit5 in one project?
![](https://androidpro.io/wp-content/uploads/2023/09/junit5-and-junit4_o-1024x512.png)
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
![](https://androidpro.io/wp-content/uploads/2023/09/kotlintesting-libraries-header_o-1024x512.png)
JVM and Kotlin testing libraries – Gradle dependencies and latest versions.
Don’t mock static: test Timber Logger with trees
![](https://androidpro.io/wp-content/uploads/2023/09/how-to-test-timber-trees-1-1024x512.jpg)
Learn how to create custom Timber Tree to test log outputs in unit tests. Mocking Timber, unit testing logs.
Don’t mock static: test SLF4J Logger with appenders
![](https://androidpro.io/wp-content/uploads/2023/09/Test-SLF4J-Logger-1--1024x512.jpg)
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.