Sep. 5th, 2023

dybr

Sep. 5th, 2023 09:37 pm
juan_gandhi: (Default)

Was spending time with Mockito, like crazy. The problem is, if you need to mock a method that has an additional list of implicit parameters, this does not work every time. Plus, what's the implicit value? Play for Scala 2.12 uses Akka HTTP, and all is done via Akka actors, and ExecutionContext is something from Akka, not the standard 'global', which is available in the test. So one needs to match the parameters, using `any[ExecutionContext]` as a matcher, and it does not work every time. I was debugging through that crazy Mockito code, until I figured that I don't need all that.

And now I know why Mockito. People use it if they can't refactor their code into manageable chunks. A trait with 50 methods, a method with 20 parameters, and the like. These people think they are programmers. They are hackers. Their brains don't serve them properly. 

So what I did. 1. Extracted a trait I need. Just one method in that trait is enough for me. 2. The class that implements does not need to get an implicit ExecutionContext in every call. It actually gets it in a constructor. So it was a cargo cult, passing the same context twice, in the constructor and in every method. Kicked it out from those calls, from those signatures. All unit tests immediately started passing.

Now I have integration tests left. There's some problem of dependencies (mockito again); maybe I should just kick it out of integration tests. Will do it tomorrow.

Tomorrow also I'm on Pager Duty. Chris left me his duty report. One of the services leaks memory. That's what I'll spend time hunting and fixing. I love this kind of shit.

Of course we had some meetings. The shortest ones are with Karen, we have a perfect rapport. Several minutes, done.

 

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

November 2025

S M T W T F S
       1
23456 7 8
9 1011 12 1314 15
16171819 20 2122
23 24 2526272829
30      

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Nov. 27th, 2025 12:04 am
Powered by Dreamwidth Studios