Hi list,

I forgot to update this thread. I just want to let you know that since we 
merged CASSANDRA-14361 to trunk which introduced mockito-inline dependency, you 
can mock static methods in trunk already.

Regards

________________________________________
From: Miklosovic, Stefan <stefan.mikloso...@netapp.com>
Sent: Thursday, January 12, 2023 14:59
To: dev@cassandra.apache.org
Subject: Re: Introducing mockito-inline library among test dependencies

NetApp Security WARNING: This is an external email. Do not click links or open 
attachments unless you recognize the sender and know the content is safe.




Hi Jacek,

that is very good question, I will try to get back to you with the answer.

Also, just before merging 14361, we noticed that we are also hitting some 
issues on mocking stuff in 
org.apache.cassandra.distributed.mock.nodetool.InternalNodeProbe which failed 
some other tests.

I remember that I wanted to mock static methods like two years ago and I hit 
the very same issue back then as I do now (1).

Please keep in mind that the error is not related to what I wanted to test for 
CASSANDRA-14361, it is rather the consequence of us including mockito-inline to 
mock static methods and as we included it into the build and run full CI, the 
completely unrelated tests started to fail because of that. This issue seems to 
be in Mockito from times of 3.x and they are still present in 4.7.0.

I was able to workaround this issue in Cassandra code. The path towards using 
static mocks is not so straightforward but should be possible with a little bit 
more love. (2)

(1) https://github.com/mockito/mockito/issues/2203
(2) https://issues.apache.org/jira/browse/CASSANDRA-18152

________________________________________
From: Jacek Lewandowski <lewandowski.ja...@gmail.com>
Sent: Thursday, January 12, 2023 13:21
To: dev@cassandra.apache.org
Subject: Re: Introducing mockito-inline library among test dependencies

NetApp Security WARNING: This is an external email. Do not click links or open 
attachments unless you recognize the sender and know the content is safe.



Will it work with Java17?

czw., 12 sty 2023, 12:56 użytkownik Brandon Williams 
<dri...@gmail.com<mailto:dri...@gmail.com>> napisał:
+1

Kind Regards,
Brandon

On Wed, Jan 11, 2023 at 2:02 PM Miklosovic, Stefan
<stefan.mikloso...@netapp.com<mailto:stefan.mikloso...@netapp.com>> wrote:
>
> Hi list,
>
> the test for (1) is using mockito-inline dependency for mocking static 
> methods as mockito-core is not able to do that on its own. mockito-inline was 
> not part of our test dependencies prior this work. I want to ask if we are 
> all OK with being able to mock static methods from now on with the help of 
> this library.
>
> Please tell me if we are mocking static methods already by some other (to me 
> yet unknown) mean so we do not include this unnecessarily.
>
> G:A:V is org.mockito:mockito-inline:4.7.0
>
> (1) https://issues.apache.org/jira/browse/CASSANDRA-14361
>
> Thanks

Reply via email to