Giter VIP home page Giter VIP logo

mockito-cookbook's Introduction

"Mockito Cookbook" Code Repository

This repository contains code present in my "Mockito Cookbook" published by Packt Publishing. You can buy the book here

The structure

Project structure

It's a multimodule project where each module represents a particular chapter of the book

  • chapter01
  • chapter02
  • ...
  • chapter10
  • common (classes used by all modules)
  • common test (test classes used by all modules)

Module structure

Each chapter contains the following package structure (example for chapter01):

chapter01
    src
        main
            java
                com
                    blogspot
                        toomuchcoding
                            chapter1
        test
            java
                com
                    blogspot
                        toomuchcoding
                            chapter1

The contents of chapters differ so in each "chapter" package (in the example above it's "chapter1" package) you will have packags related to the given chapter in the book. To make it easier for you to find the desired class I've named the chapter related packages in the following manner (example for Chapter 1):

_1_MockitoAnnotationsJunitRunner
_2_MockitoAnnotationsJunit
_3_MockitoAnnotationsTestNg
_4_MockitoGoodPractices
_5_AddingMockitoHintsToExceptionMessages

The prefix is given to sort packages in the order presented in the book. After the prefix you have the name of the recipe inside the chapter. Now let's take a look at the structure of a recipe inside this code repository:

_4_MockitoGoodPractices
    assertj
        TaxFactorCalculatorTest.java
        TaxFactorCalculatorTestNgTest.java
    fancy
        assertj
            TaxFactorCalculatorTest.java
            TaxFactorCalculatorTestNgTest.java
        hamcrest
            TaxFactorCalculatorTest.java
            TaxFactorCalculatorTestNgTest.java
    hamcrest
        TaxFactorCalculatorTest.java
        TaxFactorCalculatorTestNgTest.java

In the book in the majority of examples I'm using AssertJ for asserting objects. Since not everyone is using it and there are people who prefer to use Hamcrest that's why you can find (almost in every recipe) two packages assertj and hamcrest where you can find the same examples using two different libraries for assertions. The fancy package in the 1st chapter 4th recipe means that there is an additional example in the book. It's related to a fancy way of creating code that's why the package is named fancy. Inside that package yet again you have to approaches of asserting objects - with assertj and hamcrest. Last but not least each of the tests (almost in every recipe) is written once for JUnit and once for TestNG.

How to build it

You can build the app using gradle

    ./gradlew build

or maven

   mvn clean install

Contact

In case of any issues, doubts or if you need help with understanding sth just contact me either via email - marcin(at)grzejszczak.pl or via my blog at http://toomuchcoding.blogspot.com, or my homepage http://www.marcin.grzejszczak.pl, or Twitter - @MGrzejszczak.

Mockito Cookbook Google Group

There is also the Mockito Cookbook Google Group where you can share your thoughts on whatever is related to the book or any topic related to Mockito.

Build status

Build Status

Bitdeli Badge

mockito-cookbook's People

Contributors

bitdeli-chef avatar marcingrzejszczak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.