Test-Driven Development with Mockito


Test-Driven Development with Mockito
eBook: $23.99
Formats: PDF, PacktLib, ePub and Mobi formats
$20.39
save 15%!
Print + free eBook + free PacktLib access to the book: $63.98    Print cover: $39.99
$39.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Start writing clean, high quality code to apply Design Patterns and principles
  • Add new features to your project by applying Test-first development- JUnit 4.0 and Mockito framework
  • Make legacy code testable and clean up technical debts

Book Details

Language : English
Paperback : 172 pages [ 235mm x 191mm ]
Release Date : November 2013
ISBN : 1783283297
ISBN 13 : 9781783283293
Author(s) : Sujoy Acharya
Topics and Technologies : All Books, Application Development, Open Source

Table of Contents

Preface
Chapter 1: Getting Familiar with TDD
Chapter 2: Refactoring – Roll the Dice
Chapter 3: Applying TDD
Chapter 4: Understanding the Difference between Inside-out and Outside-in
Chapter 5: Test Doubles
Chapter 6: Mockito Magic
Chapter 7: Leveraging the Mockito Framework in TDD
Chapter 8: World of Patterns
Chapter 9: TDD, Legacy Code, and Mockito
Appendix A: TDD Tools and Frameworks
Appendix B: Agile Practices
Index
    • Chapter 2: Refactoring – Roll the Dice
      • Refactoring
        • Reasons behind refactoring
        • Refactoring schedule
        • When not to refactor
        • Stopping refactoring
        • Code smell
          • Switch statements
          • Duplicate code
          • Comments
          • Long methods and parameter list
          • Large classes (aka GOD object)
          • Agent classes
          • Lazy, dead class and dead code
          • Over engineering (speculative generality)
          • Wrong inheritance (refused bequest)
      • Summary
      • Chapter 3: Applying TDD
        • Understanding different test types
        • Understanding TDD – a real-life example
          • Definition
          • Common healthcare vocabulary
          • Procedure
          • The service catalogue
          • MRN
          • Encounter
        • Summary
            • Chapter 6: Mockito Magic
              • An overview of Mockito
                • Why you should use Mockito
              • Qualities of unit testing
              • Drinking Mockito
              • Verifying redundant invocation
                • Rationale
              • The argument matcher
                • Rationale
                • Why we need wildcard matchers
                • The ArgumentMatcher class
              • Throwing exceptions
              • Consecutive calls
              • Stubbing with callbacks – using the Answer class
              • Spying objects
              • Using doReturn()
              • Working with Void methods
              • Argument capture
              • Summary
                • Chapter 8: World of Patterns
                  • Characteristics of a bad design
                  • Design principles
                  • Design patterns
                    • Classification of patterns
                      • Replacing conditional logic with command
                      • Applying a command pattern
                    • Replacing conditional logic with strategy
                      • Strategy pattern
                  • Summary
                    • Appendix A: TDD Tools and Frameworks
                      • Discovering Eclipse
                      • Useful keys for TDD and refactoring
                      • General settings
                      • JUnit 4.x
                        • Running the first unit test
                        • Exception handling
                        • The test suite
                        • Ignoring a test
                        • Asserting a value
                      • Summary
                      • Appendix B: Agile Practices
                        • Exploring continuous integration
                        • Exploring Jenkins
                          • Configuring Jenkins
                            • Adding a build job
                            • Source code management
                            • Build triggers
                            • Scripting
                            • Post-build actions
                            • Security
                        • Revealing Agile methodologies
                          • Working with the Scrum methodology
                            • Roles
                            • Meetings
                            • The story board
                          • Exploring the Kanban development process
                        • Summary

                        Sujoy Acharya

                        Sujoy Acharya works as a software architect with Siemens Technology and Services Pvt Ltd. (STS). He grew up in a joint family and pursued his graduation in Computer Science and Engineering. His hobbies are watching movies and sitcoms, playing outdoor sports, and reading books.

                        He likes to research upcoming technologies. His major contributions are in the fields of Java, J2EE, SOA, Ajax, GWT, and the Spring framework.

                        He has authored Test-Driven Development with Mockito, Packt Publishing.He designs and develops healthcare software products. He has over 10 years of industrial experience and has architected and implemented large-scale enterprise solutions.

                        Sorry, we don't have any reviews for this title yet.

                        Code Downloads

                        Download the code and support files for this book.


                        Submit Errata

                        Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.

                        Sample chapters

                        You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                        Frequently bought together

                        Test-Driven Development with Mockito +    Mastering Web Application Development with AngularJS =
                        50% Off
                        the second eBook
                        Price for both: £21.95

                        Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                        What you will learn from this book

                        • Create your first unit test and discover the power of unit testing
                        • Familiarize yourself with Test-first Development and the refactoring process
                        • Add new features to your project applying Test Driven Development
                        • Create readable, maintainable, and extensible software using design principles and patterns
                        • Start stubbing, mocking, spying, and verifying objects using Mockito APIs
                        • Apply inside-out and outside-in TDD styles
                        • Expedite the development process using Eclipse and keyboard shortcuts
                        • Apply JUnit 4.0 and advanced Mockito features – argument captor, callbacks, and answers

                        In Detail

                        The usual life cycle of code involves adding code, breaking an existing functionality, fixing that and breaking a new area! This fragility can be fixed using automated tests and Test Driven Development.

                        TDD’s test first approach expedites the development process and unit tests act as safety nets for code refactoring and help in maintaining and extending the code. This makes TDD highly beneficial for new projects.

                        This practical, hands-on guide provides you with a number of clear, step-by-step exercises that will help you to take advantage of the real power that is behind Test Driven Development and the Mockito framework. By using this book, you will gain the knowledge that you need to use the Mockito framework in your project.

                        This book explains the concept of Test Driven Development (TDD), including mocking and refactoring, as well as breaking down the mystery and confusion that surrounds the test first approach of TDD. It will take you through a number of clear, practical examples that will help you to take advantage of TDD with the Mockito framework, quickly and painlessly.

                        You will learn how to write unit tests, refactor code and remove code smells. We will also take a look at mock objects and learn to use Mockito framework to stub, mock, verify and spy objects for testability. You will also learn to write clean, maintainable, and extensible code using design principles and patterns.

                        If you want to take advantage of using Test Driven Development and learn about mocking frameworks, then this is the book for you. You will learn everything you need to know to apply Test Driven Development in a real life project, as well as how to refactor legacy code and write quality code using design patterns.

                        Approach

                        This book is a hands-on guide, full of practical examples to illustrate the concepts of Test Driven Development.

                        Who this book is for

                        If you are a developer who wants to develop software following Test Driven Development using Mockito and leveraging various Mockito features, this book is ideal for you. You don’t need prior knowledge of TDD, Mockito, or JUnit.

                        It is ideal for developers, who have some experience in Java application development as well as a basic knowledge of unit testing, but it covers the basic fundamentals of TDD and JUnit testing to get you acquainted with these concepts before delving into them.

                        Code Download and Errata
                        Packt Anytime, Anywhere
                        Register Books
                        Print Upgrades
                        eBook Downloads
                        Video Support
                        Contact Us
                        Awards Voting Nominations Previous Winners
                        Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                        Resources
                        Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software