Mastering unit testing using Mockito and JUnit : an advanced guide to mastering unit testing using Mockito and JUnit /
A practical and easy-to-follow, yet comprehensive, guide to learning advanced JUnit testing. Each topic is explained and placed in context, and for the more inquisitive, there are more details of the concepts used. This book is for you if you are a developer with some experience in Java application...
Clasificación: | Libro Electrónico |
---|---|
Autor principal: | |
Formato: | Electrónico eBook |
Idioma: | Inglés |
Publicado: |
Birmingham, England :
Packt Publishing,
2014.
|
Colección: | Community experience distilled.
|
Temas: | |
Acceso en línea: | Texto completo |
Tabla de Contenidos:
- Cover; Copyright; Credits; About the Author; About the Reviewers; www.PacktPub.com; Table of Contents; Preface; Chapter 1: JUnit 4
- A Total Recall; Defining unit testing; Working with JUnit 4; Setting up Eclipse; Running the first unit test; Exploring annotations; Verifying test conditions with Assertion; Working with exception handling; Exploring the @RunWith annotation; Working with JUnit 4++; Ignoring a test; Executing tests in order; Learning assumptions; Exploring test suite; Asserting with assertThat; Comparing matchers
- equalTo, is, and not
- Working with compound value matchers
- either, both, anyOf, allOf, and notWorking with collection matchers
- hasItem, and hasItems; Exploring string matchers
- startsWith, endsWith, and containsString; Exploring built-in matchers; Building a custom matcher; Creating parameterized tests; Working with parameterized constructors; Working with parameterized methods; Giving a name; Working with timeouts; Exploring JUnit theories; Externalizing data using @ParametersSuppliedBy and ParameterSupplier; Dealing with JUnit rules; Playing with the timeout rule; Working with the ExpectedException rule
- Unfolding the TemporaryFolder ruleExploring the ErrorCollector rule; Working with the Verifier rule; Learning the TestWatcher rule; Working with the TestName rule; Handling external resources; Exploring JUnit categories; Summary; Chapter 2: Automating JUnit Tests; Continuous Integration; Benefits of CI; Gradle automation; Getting started; Gradling; Gradle plugins; Maven project management; Installation; The Archetype plugin; The Project Object Model (POM) file; Project dependency; The build life cycle; The clean life cycle; The site life cycle; Another Neat Tool (ANT); Jenkins
- The Gradle projectThe Maven project; Building the Ant project; Summary; Chapter 3: Test Doubles; Dummy; Stub; Fake; Mock; Spy; Summary; Chapter 4: Progressive Mockito; Working with Mockito; Why should you use Mockito?; Qualities of unit testing; Drinking Mockito; Configuring Mockito; Mocking in action; Mocking objects; Stubbing methods; Verifying the method invocation; Using argument matcher; Throwing exceptions; Stubbing consecutive calls; Stubbing with an Answer; Spying objects; Stubbing void methods; Capturing arguments with ArgumentCaptor; Verifying the invocation order
- Changing the default settingResetting mock objects; Exploring Mockito annotations; Working with inline stubbing; Determining mocking details; Behavior-driven development with Mockito; Writing tests in BDD style; The BDD syntax; Summary; Chapter 5: Exploring Code Coverage; Understanding code coverage; Learning the inner details of code instrumentation; Configuring the Eclipse plugin; Uncovering the Clover plugin; Working with the EclEmma plugin; Examining the eCobertura plugin; Measuring coverage using Gradle; Working with the Maven Cobertura plugin; Running the Cobertura Ant task; Summary