mockito lint

7 views
Skip to first unread message

Szczepan Faber

unread,
Jul 25, 2016, 11:45:48 PM7/25/16
to mocki...@googlegroups.com
Hey,

Do you guys think it would be useful to introduce some basic linting mechanism, for example, warnings on system output when:

- More than 5 mocks created in a test - code smell that we're testing too much, classes need to be refactored
- More than 4 stubbings, as above

The warnings would point to decent documentation that we would write :)

Thoughts?

Rafael Winterhalter

unread,
Jul 26, 2016, 8:11:32 AM7/26/16
to mocki...@googlegroups.com
I do not think this is a good idea. It really depends on your test and its scope of what a "good number" is. If something like that is supposed to be meaningful, the cut-off should be contextual and this seems like a lot of work.

I think, rather there should be a good: "introduction to mocking" article that should mention "best practices".

--
You received this message because you are subscribed to the Google Groups "mockito-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mockito-dev...@googlegroups.com.
To post to this group, send email to mocki...@googlegroups.com.
Visit this group at https://groups.google.com/group/mockito-dev.
For more options, visit https://groups.google.com/d/optout.

Brice Dutheil

unread,
Jul 27, 2016, 7:30:59 AM7/27/16
to mocki...@googlegroups.com
I agree with with Rafael. However mockito could provide some environment lint. Like old JDK, bad classpath, etc.

-- Brice

_____________________________
From: Rafael Winterhalter <rafae...@gmail.com>
Sent: mardi, juillet 26, 2016 14:11
Subject: Re: [mockito-dev] mockito lint
To: <mocki...@googlegroups.com>

Szczepan Faber

unread,
Jul 27, 2016, 9:47:09 AM7/27/16
to mocki...@googlegroups.com
Thanks for feedback.

It would interesting to know in what context 8 mocks in a test is a good idea :D

Cheers!
Szczepan Faber
Founder @ mockito.org | Twitter @ szczepiq
Author @ https://www.linkedin.com/today/author/6016386

Brice Dutheil

unread,
Jul 27, 2016, 10:16:15 AM7/27/16
to mocki...@googlegroups.com
Your point is valid but is beyond mockito. If there's 8 mocks, maybe someone has a good reason for it, or more likely they have designed JEE / Spring beans with 10th of dependencies. My IDE warns me about that.

-- Brice
Reply all
Reply to author
Forward
0 new messages