The New Book on Mockito Testing

75 views
Skip to first unread message

amarabha banerjee

unread,
Jul 4, 2014, 4:07:52 AM7/4/14
to moc...@googlegroups.com

Szczepan Faber

unread,
Jul 4, 2014, 4:44:23 AM7/4/14
to moc...@googlegroups.com
Congratulations Marcin on your new publication!

I always envy the book writers the persistence in getting the entire
book completed.

(In meantime I'm setting up releases into Bintray :)

Cheers!

On Fri, Jul 4, 2014 at 10:07 AM, amarabha banerjee <amar...@gmail.com> wrote:
> Check out this new book on mockito Testing.
> http://www.amazon.com/Mockito-Cookbook-Marcin-Grzejszczak/dp/1783982748/ref=sr_1_1?ie=UTF8&qid=1404460013&sr=8-1&keywords=mockito+cookbook
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "mockito" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mockito+u...@googlegroups.com.
> To post to this group, send email to moc...@googlegroups.com.
> Visit this group at http://groups.google.com/group/mockito.
> For more options, visit https://groups.google.com/d/optout.



--
Szczepan Faber
Principal engineer@gradle; Founder@mockito

Marcin Zajączkowski

unread,
Jul 4, 2014, 4:45:00 AM7/4/14
to moc...@googlegroups.com
On 2014-07-04 10:07, amarabha banerjee wrote:
> Check out this new book on mockito Testing.
> http://www.amazon.com/Mockito-Cookbook-Marcin-Grzejszczak/dp/1783982748/ref=sr_1_1?ie=UTF8&qid=1404460013&sr=8-1&keywords=mockito+cookbook

Marcin G. has become a real Mockito evangelist :). Nice.

Marcin

--
http://blog.solidsoft.info/ - Working code is not enough

Marcin Grzejszczak

unread,
Jul 4, 2014, 4:46:13 AM7/4/14
to moc...@googlegroups.com
Thanks Szczepan and Marcin :)

@Szczepan - Bintray releases of Mockito? :) BTW do you need some spare hands to do that?


Brice Dutheil

unread,
Jul 4, 2014, 4:48:05 AM7/4/14
to moc...@googlegroups.com
Congrats ;)

-- Brice

Marcin Grzejszczak

unread,
Jul 4, 2014, 4:51:40 AM7/4/14
to moc...@googlegroups.com
@Brice - the book wouldn't have been published if it wasn't for your reviews... :)

Pozdrawiam / Best regards,
Marcin Grzejszczak
Senior software developer

Brice Dutheil

unread,
Jul 4, 2014, 5:15:32 AM7/4/14
to moc...@googlegroups.com
:)

-- Brice

Szczepan Faber

unread,
Jul 4, 2014, 6:26:40 AM7/4/14
to moc...@googlegroups.com
>@Szczepan - Bintray releases of Mockito? :) BTW do you need some spare hands to do that?

Yes :) I'm making progress but I can split the work so that we can get
this done faster in parallel. Please join the dev list and I'll write
up some status (maybe today).

Cheers!

On Fri, Jul 4, 2014 at 10:46 AM, Marcin Grzejszczak
<marcin.gr...@gmail.com> wrote:

Russell Bateman

unread,
Jul 4, 2014, 11:09:04 AM7/4/14
to moc...@googlegroups.com
Thanks for the Kindle editon, Marcin. I don't have any room on my bookshelves anymore (even though I really prefer reading paper). I chose to buy that edition.

Looks good and I've already downloaded the sample code!


Marcin Grzejszczak

unread,
Jul 4, 2014, 12:01:37 PM7/4/14
to moc...@googlegroups.com
Hi Russell,

I'm glad that you like it. You can also check out the Mockito Cookbook's Github repository - https://github.com/marcingrzejszczak/mockito-cookbook . That contains all the code from the book with different approaches (TestNG vs JUnit and Hamcrest vs AssertJ).

Rogerio

unread,
Jul 11, 2014, 1:57:21 PM7/11/14
to moc...@googlegroups.com
Nice book, I may have to buy a copy myself!

I was just reading page 249 (available free on Amazon), and I noticed a couple things:

1) TaxTransfererTest (the JMockit version) can be simplified to the following, since JMockit supports the specification of invocation count constraints on recorded expectations:

    @Test
    public void should_return_false_when_tax_was_not_transfered_and_connection_to_irs_was_refused(@Mocked final TaxService taxService) {
        // given
        TaxTransferer systemUnderTest = new TaxTransferer(taxService);
        final Person person = new Person();
        new NonStrictExpectations() {{
            taxService.hasAlreadyTransferredTax(person);
            result = false;
            times = 1;

            taxService.transferTaxFor(person);
            result = new RuntimeException("Connection refused");
            times = 1;
        }};

        // when
        boolean transferSuccessful = systemUnderTest.transferTaxFor(person);

        // then
        assertThat(transferSuccessful, is(false));
    }

So, by adding the "times = 1" constraints, there is no need for a verification block, as the verifications will be done automatically.

2) Use of "@Listeners(mockit.integration.testng.Initializer.class)" is not needed if using TestNG 6.2 or newer, since the JMockit-TestNG integration is fully automatic and transparent in that case (with jars in any order in the classpath).


Congrats on the book ;)

Marcin Grzejszczak

unread,
Jul 11, 2014, 3:04:52 PM7/11/14
to moc...@googlegroups.com

Hi!

Thanks for the info on jMockit.

In order not to pollute Mockito's group I created one for Mockito Cookbook. This is the address

https://groups.google.com/forum/m/?hl=en#!forum/mockito-cookbook

As for your comments I'll reply to them once I come back firm holidays (something like 2 weeks) and won't have to respond from my Samsung (God these mobiles suck hard) :)

Glad that you seem to like the book and thanks for your comments again :)

Cheers
Marcin

Marcin Grzejszczak

unread,
Jul 19, 2014, 3:42:39 AM7/19/14
to moc...@googlegroups.com
The address to the group should be

https://groups.google.com/forum/?hl=en&nomobile=true#!forum/mockito-cookbook

the previous one was a link to the mobile version

> To unsubscribe from this group and stop receiving emails from it, send an email to mockito+unsubscribe@googlegroups.com.

Marcin Grzejszczak

unread,
Jul 23, 2014, 5:49:39 AM7/23/14
to moc...@googlegroups.com
This is the answer to Rogerio's message - https://groups.google.com/forum/#!topic/mockito-cookbook/A6HB5dMi6ho thanks Rogerio for the feedback by the way :)


W dniu piątek, 11 lipca 2014 21:04:52 UTC+2 użytkownik Marcin Grzejszczak napisał:

> To unsubscribe from this group and stop receiving emails from it, send an email to mockito+unsubscribe@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages