IN .NET Marcin Kawalerowicz Craig Berntson MANNING www.it-ebooks.info Continuous Integration in .NET www.it-ebooks.info www.it-ebooks.info Continuous Integration in .NET MARCIN KAWALEROWICZ CRAIG BERNTSON MANNING Greenwich (74° w. long.) www.it-ebooks.info For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. 180 Broad St. Suite 1323 Stamford, CT 06901 Email: orders@manning.com ©2011 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine. Manning Publications Co. 180 Broad St. Suite 1323 Stamford, CT 06901 Development editor: Copyeditor: Typesetter: Cover designer: Emily Macel Tiffany Taylor Dennis Dalinnik Marija Tudor ISBN: 9781935182559 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – MAL – 17 16 15 14 13 12 11 www.it-ebooks.info To HSD and all the “bwk” people —M.K. To Bonnie and Sherwood, the best parents a son could have —C.B. www.it-ebooks.info www.it-ebooks.info brief contents PART 1 MAKE IT HAPPEN 1 1 ■ Understanding continuous integration 3 2 ■ Setting up a source control system 29 3 4 ■ ■ Automating the build process Choosing the right CI server 66 89 5 ■ Continuous feedback 120 6 ■ Unit testing continuously integrated code 144 PART 2 EXTEND IT 165 7 8 ■ ■ Performing integration, system, and acceptance testing 167 Analyzing the code 199 PART 3 SMOOTH AND POLISH IT 225 9 10 ■ ■ Generating documentation Deployment and delivery 227 240 11 12 ■ ■ Continuous database integration Extending continuous integration 260 276 vii www.it-ebooks.info www.it-ebooks.info contents preface xv acknowledgments xvii about this book xix about the authors xxii about the cover illustration xxiii PART 1 MAKE IT HAPPEN 1 1 Understanding continuous integration 3 1.1 What does it mean to integrate continuously? 4 Defining continuous integration 4 ■ CI and your development process 5 ■ Do I need to build with every change? 7 ■ Overcoming team objections 8 ■ It’s all about reducing risk 10 1.2 1.3 A simple Hello World–type CI example 12 CI tools 13 Essential tools 14 ■ Code-analysis tools 18 Testing tools 20 ■ Other tools 20 1.4 A project for CI: leasing/credit calculator 20 1.5 Calculation core Summary 27 21 ■ Calculators 26 ix www.it-ebooks.info [...]... CI 1.1.1 Defining continuous integration One of the best definitions of continuous integration comes from Martin Fowler (www.martinfowler.com/articles/continuousIntegration.html): Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily—leading to multiple integrations per day Each integration is... and acceptance testing 167 7.1 Extending your CI test repertoire 168 Beyond unit tests in CI 169 Involving the customer or domain expert in the CI testing process 171 Right timing, right failing 172 ■ ■ 7.2 Up close and personal with integration tests in CI Performing integration testing to integration testing 176 7.3 173 Testing the user interface 173 From mocking ■ 180 Testing Windows Forms with White... Examining the CI server possibilities 92 Manual integration build or your own CI server? CI servers for NET 94 www.it-ebooks.info 92 83 86 xi CONTENTS 4.3 Continuous integration with CruiseControl.NET Starting with CCNet 96 Triggering builds 100 4.4 Continuous integration with TeamCity Running TeamCity 102 Pre-tested commit 110 4.5 95 97 Configuring CCNet ■ 102 Configuring a project ■ 104 Continuous integration. .. www.it-ebooks.info Understanding continuous integration This chapter covers ■ Continuous integration theory ■ A Hello World CI example ■ A preliminary list of CI tools As developers, we’re interested in creating the best possible applications for our customers with the least amount of work But with applications becoming more complex and having more moving parts, creating great applications is getting harder,... 261 11.2 Rolling your own continuous database integration 11.3 Continuous database maintenance with 262 RoundhousE 264 11.4 Continuous database maintenance with Visual Studio 266 Getting started with database projects 266 data 268 Unit testing stored procedures 271 Studio database maintenance into CI 274 ■ 11.5 Summary 275 www.it-ebooks.info ■ Generating test Putting Visual ■ www.it-ebooks.info xiv CONTENTS... code metrics and analysis You can also go as far as combining all the different files into an install set and making sure it works correctly Finally, don’t get caught up with the meaning of continuous CI isn’t truly continuous, because integration occurs only at specific intervals or when triggered by a specific event Integration is continuous in that it happens regularly and automatically Now that... 225 9 Generating docum entation 227 9.1 XML documentation 228 Common XML documentation tags in XML comments 231 9.2 Sandcastle 10 Formatting text ■ 233 Building with Sandcastle 9.3 228 235 ■ 237 Sandcastle in CI Summary 239 Deploym ent and delivery 240 10.1 Creating an installer for your Windows application 241 Creating a Microsoft Installer package in Visual Studio Continuously creating installation... is not production code We provide many configuration files, especially for CruiseControl.NET You can access the source code from the publisher’s website at www.manning.com/ ContinuousIntegrationin.NET Author Online Purchase of Continuous Integration in NET includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and... 10.2 Windows Installer XML toolset 244 Creating an installer using WiX with CI 247 10.3 245 ClickOnce deployment 248 Creating a ClickOnce deployment 248 in a CI scenario 251 10.4 Automating WiX ■ Web Deployment Tool ■ 253 Visual Studio 2010 and MS Deploy 254 the build server 256 10.5 11 Summary ClickOnce MS Deploy on ■ 258 Continuous database integration 260 11.1 What is continuous database integration? ... repository 42 Subversion client: TortoiseSVN 42 Creating a Updating working copy 43 Committing changes 45 and committing files 48 Referencing 50 ■ ■ ■ ■ 2.4 Setting up Team Foundation Server 53 Installing TFS 2010 53 TFS collections 55 Using Visual Studio Team Explorer 58 Managing TFS source control 61 Locking and shelving 63 ■ ■ ■ 2.5 3 Summary 64 Autom ating the build process 66 3.1 Build automation 67 . HAPPEN 1 1 Understanding continuous integration 3 1.1 What does it mean to integrate continuously? 4 Defining continuous integration 4 ■ CI. 4.3 Continuous integration with CruiseControl .NET 95 Starting with CCNet 96 ■ Configuring CCNet 97 Triggering builds 100 4.4 Continuous integration