Unit Testing and Continuous Integration.ppt_第1頁
Unit Testing and Continuous Integration.ppt_第2頁
Unit Testing and Continuous Integration.ppt_第3頁
Unit Testing and Continuous Integration.ppt_第4頁
Unit Testing and Continuous Integration.ppt_第5頁
已閱讀5頁,還剩29頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、Unit Testing and Continuous Integration,2,Agenda,Development challenges Unit Testing Overview Unit Testing with NUnit Databases and Unit Testing Integration challenges Continuous Integration with CruiseControl.NET Summary Tools of the trade,3,Development Challenges,Audit your work is it correct? Cor

2、porate knowledge (new devs) Improve development practices Broken builds Code quality Adherence to standards Peer review,4,How do we audit our work?,Looks OK to me Output window Logging Interactive debugging Test harness SQL scripts to check results,5,Corporate Knowledge,Application,1yr,2yr,4yr,3yr,5

3、yr,End of useful life,1st Upgrade,2nd Upgrade,Developer 1,Developer 2,Developer 3,Developer 4,User 1,User 2,6,Multiple releases to Test,Few releases to UAT,Single release to Production,Every testing phase incurs a cost,Every deployment incurs a cost,7,Unit Testing Overview,“a unit test is a procedur

4、e used to verify that a particular module of source code is working properly” - . Developer-focused testing Tests module outputs Component integration testing,8,NUnit,Unit-testing framework for .NET Write your unit tests in .NET GUI and console UI Run unit test(s) against available meth

5、ods Use .NET attributes (Test) to identify unit tests Test expected (and unexpected!) results Add-ins support Windows Forms and ASP.NET UI testing,9,Unit tests passed successfully,Unit tests failed,Errors and failure details,10,Unit Test C# Example,Test attribute marks the method as an NUnit test,NU

6、nit requires public methods for each test,Assert statements are used to test results,11,Writing Unit Tests: Rules,Tests require a known data state Autonomous Isolated Granular Repeatable (cleans up after itself) Use static methods for common tasks Instantiating objects Create test data,12,What to Un

7、it Test,Function: InsertRecord,InsertRecordValid,InsertRecordInvalidData,InsertRecordPermissionDenied,InsertRecordDuplicate,1. Record is added successfully,2. Invalid data was provided,3. User does not have permission,4. Record already exists (duplicate),Function results:,Unit tests required:,13,Wha

8、t not to Unit Test,Asynchronous processes Delayed processes Load/performance,14,Unit Tests and Databases,Dependent on your db environment Options to maintain a known data state: Restore database (SQL) Script to delete data Unit tests delete data Use transactions Use (DTC) transactions (XtUnit) Schem

9、a changes hurt!,15,Case Study: IRIS,WinForms C# app, n-tier, SQL2K db, 100 client installations 50,000 LOC (source: Code Counter Pro) Unit tests exercise Business layer Currently 700 unit tests 70% code coverage (source: NCover),16,Percentage of modules tested,Highlights areas not visited,Drill down

10、 to code level,17,Unit Tests and IRIS,Business Layer: 8,783 LOC,Unit Tests: 15,879 LOC,The Rest: 27,005 LOC,18,How to Unit Test w/ NUnit,You need: NUnit .NET Framework Runtime 1.1 or 2.0 XtUnit (if MS-DTC works for you) GUI, Command-line, TestDriven.NET In-class (#if directives) or separate project

11、Coverage percentage or target-test Write unit tests first, then make them work,19,Unit Testing Advantages,Ensures code “does what it says on the tin” Increased change confidence Reduce number of testing phases Reduce issue priority (high - medium, medium - low) Evaluate upgrade break-factor Automate

12、d, repeatable,20,Unit Testing Disadvantages,Can require more code than app! Seems like “catch-up” when tests fail,21,Integration Challenges,Shared Module,Shared Module,“Integration” occurs when changes are merged with the source code repository,22,Broken Integration,You have a broken integration whe

13、n: Source code server has a “broken build” Shared component works in one system, but breaks others Unit tests fail Code quality fails (coding conventions) Deployment fails,23,Continuous Integration,“an integration can occur at any point when the code compiles and all the unit tests are passing” - Co

14、nfluence, “What is continuous integration?” Part of the agile development methodology “Minutes” away from integration Next logical step after daily builds Highlights broken integrations Reference: Martin Fowler, Matthew Foemmel “Continuous Integration” (,24,CruiseControl.NET,Continuous Integration S

15、erver - C# service Monitors source control repository for changes to code Runs tasks, reports progress and outcomes ASP.NET status interface, tray client Isolated build server Free, supports plug-in tasks,25,26,Monitors projects/paths in source repository,Executes tasks on schedule/event,Results mer

16、ged into final report,27,How to implement CC.NET,Dedicated “clean” build machine (can be XP, Win2K3, etc) Install .NET Framework SDK(s) Write and test NAnt build scripts Build Unit test with Code coverage Coding standards Deploy Install and configure CC.NET Create “autobuild” VSS read-only account I

17、nstall CCTray on PCs,28,ccnet.config, false C:DevelopmentBuildAutoBuild C:DevelopmentBuildAutoBuild http:/iocaste/ccnet/default.aspx?_action_ViewProjectReport=trueproject=AutoBuild 10 $/Internal/OPS Automated Build Scripts autobuild your_password_here C:DevelopmentBuildAutoBuild true ,Define a stand

18、ard build folder hierarchy,Ensures check-ins are completed,Use trigger sections to check for changes,Source code interface,Build “state” maintained in this folder,29,Cont. Integration Pros,Prove your system can build! Broken builds caught early Integration testing performed early Increase code quality with additional tasks Discover potential deployment issues,30,Cont. Integration Cons,Tough to move an existing system into CI Systems that rely on “server” components (BizTalk, Sharepoint, etc.) Db-bas

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論