Mastering Unit Testing Using Mockito and JUnit

An advanced guide to mastering unit testing using Mockito and JUnit

Mastering Unit Testing Using Mockito and JUnit

Mastering
Sujoy Acharya

An advanced guide to mastering unit testing using Mockito and JUnit
$26.99
$43.99
RRP $26.99
RRP $43.99
eBook
Print + eBook

Instantly access this course right now and get the skills you need in 2016

With unlimited access to a constantly growing library of over 3,500 courses, a subscription to Mapt gives you everything you need to get that next promotion or to land that dream job. Cancel anytime.

+ Collection
Free Sample

Book Details

ISBN 139781783982509
Paperback314 pages

Book Description

It is insanity to keep doing things the same way and expect them to improve. Any program is useful only when it is functional; hence, before applying complex tools, patterns, or APIs to your production code, checking software functionality is must. Automated JUnit tests help you verify your assumptions continuously, detect side effects quickly, and also help you save time.

This book will provide the skills you need to successfully build and maintain meaningful JUnit test cases. You will begin with how to use advanced JUnit 4 features, improve code coverage, automate JUnit tests, monitor code quality, write JUnit tests for the database and web tier refactor legacy code, mock external dependencies using Mockito, and write testable code using test-driven development. By sequentially working through the steps in each chapter, you will quickly master the advanced JUnit features.

Table of Contents

Chapter 1: JUnit 4 – a Total Recall
Defining unit testing
Working with JUnit 4
Working with JUnit 4++
Summary
Chapter 2: Automating JUnit Tests
Continuous Integration
Jenkins
Summary
Chapter 3: Test Doubles
Dummy
Stub
Fake
Mock
Spy
Summary
Chapter 4: Progressive Mockito
Working with Mockito
Drinking Mockito
Summary
Chapter 5: Exploring Code Coverage
Understanding code coverage
Configuring the Eclipse plugin
Measuring coverage using Gradle
Working with the Maven Cobertura plugin
Running the Cobertura Ant task
Summary
Chapter 6: Revealing Code Quality
Understanding the static code analysis
Working with the Checkstyle plugin
Exploring the FindBugs plugin
Working with the PMD plugin
Monitoring code quality with SonarQube
Getting familiar with false positives
Summary
Chapter 7: Unit Testing the Web Tier
Unit testing servlets
Playing with Spring MVC
Summary
Chapter 8: Playing with Data
Separating concerns
Unit testing the persistence logic
Simplifying persistence with Spring
Verifying the system integrity
Writing integration tests with Spring
Summary
Chapter 9: Solving Test Puzzles
Working with the legacy code
Designing for testability
Working with greenfield code
Summary
Chapter 10: Best Practices
Writing meaningful tests
Automating JUnit tests
Configuring tests
Working with assertions
Handling exceptions
Working with test smells
Summary

What You Will Learn

  • Write advanced JUnit test cases using advanced JUnit 4 features
  • Automate JUnit test cases using Gradle, Maven, and Ant scripting
  • Practice continuous integration with Jenkins and Ant, Maven, and Gradle scripting
  • Monitor code quality with the SonarQube dashboard
  • Analyze static code using PMD, Checkstyle, and FindBugs
  • Master code coverage with Clover, Cobertura, EclEmma, and JaCoCo
  • Design for testability and refactor legacy code
  • Practice test-driven development with Mockito

Authors

Table of Contents

Chapter 1: JUnit 4 – a Total Recall
Defining unit testing
Working with JUnit 4
Working with JUnit 4++
Summary
Chapter 2: Automating JUnit Tests
Continuous Integration
Jenkins
Summary
Chapter 3: Test Doubles
Dummy
Stub
Fake
Mock
Spy
Summary
Chapter 4: Progressive Mockito
Working with Mockito
Drinking Mockito
Summary
Chapter 5: Exploring Code Coverage
Understanding code coverage
Configuring the Eclipse plugin
Measuring coverage using Gradle
Working with the Maven Cobertura plugin
Running the Cobertura Ant task
Summary
Chapter 6: Revealing Code Quality
Understanding the static code analysis
Working with the Checkstyle plugin
Exploring the FindBugs plugin
Working with the PMD plugin
Monitoring code quality with SonarQube
Getting familiar with false positives
Summary
Chapter 7: Unit Testing the Web Tier
Unit testing servlets
Playing with Spring MVC
Summary
Chapter 8: Playing with Data
Separating concerns
Unit testing the persistence logic
Simplifying persistence with Spring
Verifying the system integrity
Writing integration tests with Spring
Summary
Chapter 9: Solving Test Puzzles
Working with the legacy code
Designing for testability
Working with greenfield code
Summary
Chapter 10: Best Practices
Writing meaningful tests
Automating JUnit tests
Configuring tests
Working with assertions
Handling exceptions
Working with test smells
Summary

Book Details

ISBN 139781783982509
Paperback314 pages
Read More

Read More Reviews