![]() If you are still reading, I’m assuming you are in the same situation. Since I wanted to have confidence that my change is not breaking anything and does exactly the thing I want, I needed to write a test. I needed to change what exactly we are sending, and I had to add more attributes. If simplified, it looks something like this: NewRelicClient.addAttributesToCurrentRequest(“orderId”, order.id) ![]() To use it I had to call a static method on some class. Let me show you what I mean with a rough example that I have been dealing with recently. That is how I feel when I see such awful APIs: (source: ) I have been working with Kotlin in production for about two years at the time of writing this. I’m a fanatic of testing and test-driven development evangelist for the last five years - they call me TDD Fellow for a reason. Perhaps you ask yourself, “When will third-party library authors stop using static methods?”Īnyway, who am I to tell you how to test static method calls in Kotlin? ![]() You are not sure how to approach that problem. And you want to test some code using these static methods. The API that the library provides is one or a few static methods. Let me make a wild guess… You have encountered some code in Kotlin that is using some third-party library. By Oleksii Fedorov A stress-free way to test frustrating static method calls in Kotlin
0 Comments
Leave a Reply. |