1. 首页
  2. 服务器应用
  3. Web服务器
  4. Mastering Unit Testing Using Mockito and JUnit

Mastering Unit Testing Using Mockito and JUnit

上传者: 2018-12-25 18:56:33上传 PDF文件 17.71MB 热度 86次
Mastering Unit Testing Using Mockito and JUnitMastering Unit Testing using mockito and JUnitCopyright C 2014 Packt PublishingAll rights reserved. No part of this book may be reproduced, stored in a retrievalsystem, or transmitted in any form or by any means, without the prior writtenpermission of the publisher, except in the case of brief quotations embedded incritical articles or reviewsEvery effort has been made in the preparation of this book to ensure the accuracyof the information presented. However, the information contained in this book issold without warranty cither express or implied. Neither the author, nor PacktPublishing and its dealers and distributors will be held liable for any damagescaused or alleged to be caused directly or indirectly by this bookPackt Publishing has endeavored to provide trademark information about all of thecompanies and products mentioned in this book by the appropriate use of capitalsHowever, Packt Publishing cannot guarantee the accuracy of this informationFirst published July 2014Production reference: 1080714Published by Packt Publishing LtdLivery place35 Livery streetBirmingham b3 2PB, UKISBN978-1-78398-250-9www.packtpub.comwww.allitebooks.comCreditsAuthorProject CoordinatorSujoy acharyaLeena purkaitReviewersProofreadersJose muanis castroSimran BhogalAlexey GrigoreMaria GouldDaniel pacakAmeesha greenCommissioning EditoIndexerAmarabha BanerjeeRekha nairAcquisition EditorGraphicsMeeta rajaAbhinash sahContent Development EditorProduction coordinatorBalaji naiduMelwyn D'saTechnical editorsCover workNeha mankareMelwyn d'saEdwin mosesCover ImageCopy EditorDisha hariaRadula Hegdewww.allitebooks.comabout the authorSujoy acharya works as a software architect with Siemens Technology andServices Pvt Ltd (STS). He grew up in a joint family and pursued his graduation inComputer science and engineering his hobbies are watching movies and sitcomsplaying outdoor sports, and reading booksHe likes to research upcoming technologies. His major contributions are in the fieldsof Java, J2EE, SOA, Ajax, GWT, and the Spring frameworkHe has authored Test-Driven development with Mockito, Packt Publishing. He designsand develops healthcare software products. He has over 10 years of industrialexperience and has architected and implemented large-scale enterprise solutionsI would like to thank my wife, Sunanda, for her patience and endlesssupport in spending many hours reviewing my draft and providingvaluable inputsI would also like to thank my mother and late father for theirsupport, blessings, and encouragementTo my one-year-old kid, Abhigyan, I am sorry I couldn,'t be aroundwith you as much as we all wanted, and often, I had to get you awayfrom the laptop. I love you very muchwww.allitebooks.comabout the reviewersJose Muanis Castro holds an Information Systems degree. Originally from Rio deJaneiro, he now lives in Brooklyn with his wife and kids. He is a software engineert The New York Times, where he works with recommendation systems on thepersonalization team. Previously, he worked on the CMs and publishing platformsIt Globo. com, the biggest media portal of BrazilHe is a seasoned engineer with a history of hands-on experience in severallanguages. He's passionate about continuous improvement in Agile and Leanprocesses. With years of experience in automation, right from testing to deploying,he constantly switches hats between development and operations. When he's notcoding, he enjoys riding his bike around. His Twitter handle is omuanisIm thankful to my wife marcia and my kids, Vitoria and Rafael, forunderstanding that I couldn't be there at times with them while Iwas helping to review this bookAlexey grigore is an experienced software developer with several years ofprofessional Java programming. From the beginning, he successfully adopted thebest practices in Extreme Programming (Xp), one of which is testing, and drove hisconstantly developing requirements his team managed to quickly deliver underteammates to use it. In many cases, he witnessed testing save projects whethe changesRight now, he is a freelancer who specializes in machine learning and data mining,and he also successfully adopts TDD and testing in these fields to ensure thereliability of his applicationsForanyquestionsyoucancontacthimviaalexey.s.grigorievogmail.comwww.allitebooks.comDaniel Pacak is a self-made software engineer who fell in love with codingduring his studies of Nuclear Physics at Warsaw University of TechnologyThis was back in 2006 when no one cared about unit testing at all. He acquiredhis professional experience by working on several business-critical projects mainlyweb applications, for clients in financial services, telecommunications, e-commerce,and the travel industryWhen he's not coding he enjoys lifting weights in the gym close to his officewww.allitebooks.comwww.Packtpub.comSupport files, e Books, discount offers,and moreYoumightwanttovisitwww.Packtpub.comforsupportfilesanddownloadsrelatedtovour bookDid you know that Packt offers e Book versions of every book published, with PDF and ePubfilesavailableYoucanupgradetotheebookversionatwww.Packtpubcomandasaprintbook customer, you are entitled to a discount on the e book copy. Get in touch with us atservice@packtpub com for more detailsAtwww.packtpub.comyoucanalsoreadacollectionoffreetechnicalarticlessignupforarange of frcc newsletters and receive exclusive discounts and offers on packt books and eBooksPACKTLIB°http://packtlib.Packtpub.comDo you need instant solutions to your If questions? PacktLib is Packt's online digital booklibrary. Here, you can access, read and search across Packt's entire library of booksWhy subscribe?Fully searchable across every book published by PacktCopy and paste, print and bookmark contentOn demand and accessible via web browserFree access for packt account holdersIfyouhaveanaccountwithPacktatwww.Packtpub.comyoucanusethistoaccessPacktLib today and view nine entirely free books Simply use your login credentials forimmediate accesswww.allitebooks.comwww.allitebooks.comTable of contentsPrefaceChapter 1: JUnit 4-a Total RecallDefining unit testing9Working with JUnit 410Setting up EclipseRunning the first unit test12Exploring annotationsVerifying test conditions with Assertion16Working with exception handling19Exploring the @RunWith annotation20Working with JUnit 4++20Ignoring a test20Executing tests in order21Learning assumptions23Exploring the test suite24Asserting with assertThat25Comparing matchers-equalTo, is, and notWorking with compound value matchers-either, both, anyOf, allOt, and notWorking with collection matchers-hasItem and hasltems6Z9gExploring string matchers-starts With, ends With, and contains StringExploring built-in matchersBuilding a custom matcherCreating parameterized tests34Working with parameterized constructors34Working with parameterized methodsGiving a nameWorking with timeouts39Exploring jUnit theories40Externalizing data using @Parameters SuppliedBy and Parameter Supplier44Dealing with JUnit rules47Playing with the timeout rule47www.allitebooks.com
用户评论