Continuous Integration
Stanislav Tyurikov
Business Goal
Profit increasing
Total Profit = Project Profit [1] + … + Project Profit [N]
Project Profit = Project Revenue – Project Costs
Increase project
count
Increase project
price
Decrease project
costs
Lean Software Development: Wastes
• Defects
• Overproduction
• Transportation
• Waiting
• Inventory
• Motion
• Extra processing
Cost of change
Requarements Design Coding Testing Production
Costofchange
Project phase
What Continuous Integration is?
Continuous integration (CI) implements continuous processes of
applying quality control - small pieces of effort, applied
frequently. Continuous integration aims to improve the quality of
software, and to reduce the time taken to deliver it, by replacing
the traditional practice of applying quality control after
completing all development.
© http://en.wikipedia.org/wiki/Continuous_integration
Feedback
Mechanism
commit changes
(1)
Version
Control System
Continuous
Integration System
Build Script
Developers
Poll (2)
Report (4)
Execute (3)
Compile Source Code
Run Inspections
Run DB Scripts
Run Tests
Deploy Software
Look (5)
CI Scenario
• Write Automated Developer Tests
• Run Private Builds
• All Tests and Inspections Must Pass
• Don’t Commit Broken Code
• Fix Broken Builds Immediately
• Commit Code Frequently
• Avoid Getting Broken Code
• Run Manual Integration Builds (optional)
Developer
• Separate Build Scripts from Your IDE
• Automate Builds
• Perform Single Command Builds
• Build for Any Environment
• Fail Builds Fast
Build Script
• Centralize Software Assets
• Create a Consistent Directory Structure
Version Control System
• CI Server always available
• Use a Dedicated Integration Build Machine
• Stage Builds
CI Server
• Getting the right information to the right people at
the right time and in the right way—CI is the best
tool for making this feedback automated, targeted,
and real-time (continuous).
• Email, IM, SMS an other feedback mechanisms can
be used.
Feedback Mechanism
• Reduce Code Complexity
• Perform Design Reviews Continuously
• Maintain Organizational Standards with Code Audits
• Reduce Duplicate Code
• Assess Test Code Coverage (after test execution)
Continuous Inspection
Compilation Inspection Testing Deployment
Continuous Integration
What Continuous Testing is?
• Is a part of continuous integration process
• Test are created on development phase
• All test are automated
• Tests are frequently executed
Continuous Integration
Compilation Inspection Testing Deployment
Continuous Test Types
• Unit Tests
• Component (Integration) Tests
• System Tests
• Functional (Acceptance, Story) Tests
DB
API
UI
Automate Unit Test
Unit Test verifies the behavior of small elements in a software
system, which are most often a single class or method. Every UT
must have several characteristics (F.I.R.S.T.):
• Fast
takes a little time to execute (less than 0,01 sec).
• Isolated
does not interact with over parts of a system, failure reasons become obvious.
• Repeatable
run repeatedly in any order, any time.
• Self-Checking
no manual evaluation required.
• Timely
written before the code.
DB
API
UI
Automate Component Tests
• Component or subsystem tests verify portions of a
system and may require a fully installed system or
some external dependencies, such as databases, file
systems, or network endpoints, to name a few.
• Tend to run longer than UT.
DB
API
UI
Automate System Tests
• System tests exercise a complete software system
and therefore require a fully installed system, such
as a servlet container and associated database.
• Tend to run longer than CT.
• Use system API to perform testing.
DB
API
UI
Automate Functional Tests
• Functional tests, as the name implies, test the
functionality of an application from the viewpoint of
a client, which means the tests themselves mimic
clients (for example, using Silenium).
• Tend to run longer than ST.
DB
API
UI
Functional Tests
System Tests
Test Scopes
Data Access
Object
Business
Logic Service
Web Service
DB
Web Page
Unit Tests
Integration
Tests
Run Faster Test First
Unit Test Component Test System Test Functional Test
Also known as Integration Test
Acceptance/Story
Test
Depends on
Execution Time ms sec min hour
Description
Check class,
method
Test component
integrity, DB
queries.
System API (WS,
JNDI, etc), external
client interaction
Customer oriented.
Use UI controls,
pages, links, etc.
execution order
Each kind of test has its own area of responsibility, setup efforts, and accordingly,
different execution time.
• Set of test works like safety net. Once a new test is added, it will always
cover target functionality.
• If defect has been found, you can create additional test case for it (defect-
driven development). This makes your safety net much effective to prevent
defect reappearance.
add new test cases to make
the safety net much effective
Safety Net & Defect-Driven Development
• Release Working Software Any Time, Any Place
• Label a Repository’s Assets
• Produce a Clean Environment
• Label Each Build
• Run All Tests
• Create Build Feedback Reports
• Possess Capability to Roll Back Release
Continuous Deployment
Compilation Inspection Testing Deployment
Continuous Integration
The most typical problems which CI solves:
• “It Works on My Machine”
• “The Missing Click“
• “Did You Get the Memo?”
• Regression Testing
• Inability to Visualize Software
• Coding Standard Adherence
• Code Duplication
Typical problems
Without Continuous Testing:
With Continuous Testing:
time
time
Without CT lots of efforts and time are spent to find bugs and apply CR. CTs make
these activities more painless, but we have to create and support test as well.
Automated Tests:
1) Increase coding time.
2) Decrease bug searching/debugging time.
3) Decrease functionality modification time.
Coding Bug Fixing Functionality Modification
Coding Bug Fixing Functionality Modification
Time Saving Hypothesis
Additional Information
Books & articles:
• Continuous Integration: Improving Software Quality and Reducing Risk.
• Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation.
• Implementing Lean Software Development: From Concept to Cash.
• The Art of Lean Software Development.
• Continuous Integration by Martin Fowler.
Google it! =)

Continuous Integration

  • 1.
  • 2.
    Business Goal Profit increasing TotalProfit = Project Profit [1] + … + Project Profit [N] Project Profit = Project Revenue – Project Costs Increase project count Increase project price Decrease project costs
  • 3.
    Lean Software Development:Wastes • Defects • Overproduction • Transportation • Waiting • Inventory • Motion • Extra processing
  • 4.
    Cost of change RequarementsDesign Coding Testing Production Costofchange Project phase
  • 5.
    What Continuous Integrationis? Continuous integration (CI) implements continuous processes of applying quality control - small pieces of effort, applied frequently. Continuous integration aims to improve the quality of software, and to reduce the time taken to deliver it, by replacing the traditional practice of applying quality control after completing all development. © http://en.wikipedia.org/wiki/Continuous_integration
  • 6.
    Feedback Mechanism commit changes (1) Version Control System Continuous IntegrationSystem Build Script Developers Poll (2) Report (4) Execute (3) Compile Source Code Run Inspections Run DB Scripts Run Tests Deploy Software Look (5) CI Scenario
  • 7.
    • Write AutomatedDeveloper Tests • Run Private Builds • All Tests and Inspections Must Pass • Don’t Commit Broken Code • Fix Broken Builds Immediately • Commit Code Frequently • Avoid Getting Broken Code • Run Manual Integration Builds (optional) Developer
  • 8.
    • Separate BuildScripts from Your IDE • Automate Builds • Perform Single Command Builds • Build for Any Environment • Fail Builds Fast Build Script
  • 9.
    • Centralize SoftwareAssets • Create a Consistent Directory Structure Version Control System
  • 10.
    • CI Serveralways available • Use a Dedicated Integration Build Machine • Stage Builds CI Server
  • 11.
    • Getting theright information to the right people at the right time and in the right way—CI is the best tool for making this feedback automated, targeted, and real-time (continuous). • Email, IM, SMS an other feedback mechanisms can be used. Feedback Mechanism
  • 12.
    • Reduce CodeComplexity • Perform Design Reviews Continuously • Maintain Organizational Standards with Code Audits • Reduce Duplicate Code • Assess Test Code Coverage (after test execution) Continuous Inspection Compilation Inspection Testing Deployment Continuous Integration
  • 13.
    What Continuous Testingis? • Is a part of continuous integration process • Test are created on development phase • All test are automated • Tests are frequently executed Continuous Integration Compilation Inspection Testing Deployment
  • 14.
    Continuous Test Types •Unit Tests • Component (Integration) Tests • System Tests • Functional (Acceptance, Story) Tests DB API UI
  • 15.
    Automate Unit Test UnitTest verifies the behavior of small elements in a software system, which are most often a single class or method. Every UT must have several characteristics (F.I.R.S.T.): • Fast takes a little time to execute (less than 0,01 sec). • Isolated does not interact with over parts of a system, failure reasons become obvious. • Repeatable run repeatedly in any order, any time. • Self-Checking no manual evaluation required. • Timely written before the code. DB API UI
  • 16.
    Automate Component Tests •Component or subsystem tests verify portions of a system and may require a fully installed system or some external dependencies, such as databases, file systems, or network endpoints, to name a few. • Tend to run longer than UT. DB API UI
  • 17.
    Automate System Tests •System tests exercise a complete software system and therefore require a fully installed system, such as a servlet container and associated database. • Tend to run longer than CT. • Use system API to perform testing. DB API UI
  • 18.
    Automate Functional Tests •Functional tests, as the name implies, test the functionality of an application from the viewpoint of a client, which means the tests themselves mimic clients (for example, using Silenium). • Tend to run longer than ST. DB API UI
  • 19.
    Functional Tests System Tests TestScopes Data Access Object Business Logic Service Web Service DB Web Page Unit Tests Integration Tests
  • 20.
    Run Faster TestFirst Unit Test Component Test System Test Functional Test Also known as Integration Test Acceptance/Story Test Depends on Execution Time ms sec min hour Description Check class, method Test component integrity, DB queries. System API (WS, JNDI, etc), external client interaction Customer oriented. Use UI controls, pages, links, etc. execution order Each kind of test has its own area of responsibility, setup efforts, and accordingly, different execution time.
  • 21.
    • Set oftest works like safety net. Once a new test is added, it will always cover target functionality. • If defect has been found, you can create additional test case for it (defect- driven development). This makes your safety net much effective to prevent defect reappearance. add new test cases to make the safety net much effective Safety Net & Defect-Driven Development
  • 22.
    • Release WorkingSoftware Any Time, Any Place • Label a Repository’s Assets • Produce a Clean Environment • Label Each Build • Run All Tests • Create Build Feedback Reports • Possess Capability to Roll Back Release Continuous Deployment Compilation Inspection Testing Deployment Continuous Integration
  • 23.
    The most typicalproblems which CI solves: • “It Works on My Machine” • “The Missing Click“ • “Did You Get the Memo?” • Regression Testing • Inability to Visualize Software • Coding Standard Adherence • Code Duplication Typical problems
  • 24.
    Without Continuous Testing: WithContinuous Testing: time time Without CT lots of efforts and time are spent to find bugs and apply CR. CTs make these activities more painless, but we have to create and support test as well. Automated Tests: 1) Increase coding time. 2) Decrease bug searching/debugging time. 3) Decrease functionality modification time. Coding Bug Fixing Functionality Modification Coding Bug Fixing Functionality Modification Time Saving Hypothesis
  • 25.
    Additional Information Books &articles: • Continuous Integration: Improving Software Quality and Reducing Risk. • Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation. • Implementing Lean Software Development: From Concept to Cash. • The Art of Lean Software Development. • Continuous Integration by Martin Fowler. Google it! =)