Top Banner
37

Unit Testing and Continuous Integration in context of IFDK reference product

Dec 31, 2015

Download

Documents

tashya-alvarado

Unit Testing and Continuous Integration in context of IFDK reference product. About this course material. This material if for general training for Test Design and management Material is more supportive in class room Material will be updated during courses - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Unit Testing  and  Continuous Integration in context of IFDK  reference product
Page 2: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Unit Testing and Continuous Integrationin context of IFDK reference product

Page 3: Unit Testing  and  Continuous Integration in context of IFDK  reference product

About this course material- This material if for general training for

Test Design and management- Material is more supportive in class

room - Material will be updated during courses- FreeNest Portable Project Platform is

used to demonstrate things only in practice. This is not limiting usage for material for other training environments (I hope )

About material

Page 4: Unit Testing  and  Continuous Integration in context of IFDK  reference product

TESTING LEVELS

Page 5: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Unit/Module/Component Testing

Unit/Module/Component Testing

Customer/BusinessRequirements

Customer/BusinessRequirements

Sub SystemRequirementsSub System

Requirements

ComponentRequirementsComponent

RequirementsComponent / Unit

TestingComponent / Unit

Testing

IntegrationTestingIntegrationTesting

SystemTestingSystemTesting

AcceptanceTestingAcceptanceTesting

SystemRequirements

SystemRequirements

Architecture&Design&

Implementation

Architecture&Design&

Implementation

ProductProduct

VALIDATIONVALIDATION

VERIFICATIONVERIFICATION

Yläotsikko

Page 6: Unit Testing  and  Continuous Integration in context of IFDK  reference product

How to Test?How to Test?

What should be tested?

How ?

Page 7: Unit Testing  and  Continuous Integration in context of IFDK  reference product

How to verify component implementation

How to verify component implementation

-Unit Testing-Static Analyze-Dynamic Analyze

-Unit Testing-Static Analyze-Dynamic Analyze

Yläotsikko

Page 8: Unit Testing  and  Continuous Integration in context of IFDK  reference product

What should be tested?What should be tested?

Input ?Input ?

Output?Output?

Page 9: Unit Testing  and  Continuous Integration in context of IFDK  reference product

• Class Diagram

http://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/

Page 10: Unit Testing  and  Continuous Integration in context of IFDK  reference product

• xUnit Framework

http://en.wikipedia.org/wiki/XUnit

ImplementationImplementation

Test Framework

Page 11: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Component /Unit TestingComponent /Unit Testing

ClassClass

AttributesAttributes

ClassClass

MethodsMethods

ClassClass

AttributesAttributes

ClassClass

MethodsMethods

AttributesAttributes

TestClassTestClass

TestMethodCallTestMethodCall

Unit Test Frame WorkUnit Test Frame Work

Test Method Call

Method Result

A=1B=2C=Class.TestMethodCountValues(A+B)C<>3 FAILC=3 PASS

Implemented Class

MethodCountValues( int x, int y)z=x+y+1Return z

Developer

Page 12: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Test Driven Development and Unit TestingTest Driven Development and Unit Testing

ClassClass

AttributesAttributes

ClassClass

MethodsMethods

ClassClass

AttributesAttributes

ClassClass

MethodsMethods

AttributesAttributes

TestClassTestClass

TestMethodCallTestMethodCall

Unit Test Frame WorkUnit Test Frame Work

Test Method Call

Method Result

A=1B=2C=Class.TestMethodCountValues(A+B)C<>3 FAILC=3 PASS

Implemented Class

MethodCountValues( int x, int y)z=x+y+1Return z

Developer

DEFINE TEST CASES

FIRST!!!

DEFINE TEST CASES

FIRST!!!

IMPLEMENTCODE

AGAINST TESTS

IMPLEMENTCODE

AGAINST TESTS

Page 13: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Ideal project team and unit testingIdeal project team and unit testing

ImplementedSoftware

Component#1

ImplementedSoftware

Component#1

ImplementedSoftware Component

#3

ImplementedSoftware Component

#3

ImplementedSoftware Component

#4

ImplementedSoftware Component

#4

ImplementedSoftware Component

#2

ImplementedSoftware Component

#2

Software ProductIntegration

Software ProductIntegration

Developer 1 Developer 2 Developer 3 Developer 4

Test Sand Box Test Sand Box Test Sand Box Test Sand Box

TESTS TESTS TESTS TESTS

Integration test engineer #2Integration test engineer #1

Page 14: Unit Testing  and  Continuous Integration in context of IFDK  reference product

• Static Code Analyze

Analyzing your implementation?

10 CLS: PRINT TAB(15); "Polysons': PRINT 20 PI=3. 14159: TP=PI*2 30 INPUT "Number of Sides';SD 40 INPUT "Size (5 to 80)';SZ 50 SP=TP/SD 60 SCREEN 1 70 FOR A=0 TO TP+SP/2 STEP SP 90 X=SZ*SIN(A)+100 100 Y=SZ OS(A)+96 110 IF A=0 THEN 130 120 LINE (X0, Y0)-(X, Y) 130 X0=X:Y0=Y 140 NEXT 150 GOTO 150

http://www.atarimagazines.com/creative/v10n5/158_Simple_screen_graphics_wi.php

?

Page 15: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Code CoverageCode Coverage

An analysis method that determines which parts of

the software have been executed (covered) by the

test suite and which parts have not been executed,

e.g. statement coverage, decision coverage or

condition coverage.

http://en.wikipedia.org/wiki/Code_coverage

http://www.atlassian.com/software/clover/

Yläotsikko

http://en.wikipedia.org/wiki/Cyclomatic_complexity

http://java.net/projects/hudson/lists/dev/archive/2009-03/message/235

Page 16: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Code Coverage - Branch coverageCode Coverage - Branch coverage

The percentage of branches that have been

exercised by a test suite. 100% branch coverage

implies both 100% decision coverage and 100%

statement coverage.

Yläotsikko

http://booster911.hubpages.com/hub/BranchDecisionTesting

Page 17: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Code Coverage - Line coverageCode Coverage - Line coverage

The percentage of branches that have been

exercised by a test suite. 100% branch coverage

implies both 100% decision coverage and 100%

statement coverage.

Yläotsikko

http://booster911.hubpages.com/hub/BranchDecisionTesting

Page 18: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Static Code Analyze – Heat MapStatic Code Analyze – Heat Map

Yläotsikko

http://www.statsvn.org/demo/ruby/

Page 19: Unit Testing  and  Continuous Integration in context of IFDK  reference product

FeatureComponentFeatureComponent

Project ManagerProject Manager

Designer/CoderDesigner/Coder

IntegrationTest EngineerIntegrationTest Engineer

Test ManagerTest Manager

System TestingSystem Testing

Feature Unit/Integration TestingFeature Unit/Integration Testing

System Acceptance TestingSystem Acceptance Testing

SystemTest EngineerSystemTest Engineer

Test AutomationEngineerTest AutomationEngineer

AcceptanceTest EngineerAcceptanceTest Engineer

ValidationValidation

VerificationVerification

Product verification/validation and test automation Product verification/validation and test automation

Regression TestingRegression Testing

Integration TestingIntegration Testing

Functional System TestingFunctional System Testing

Acceptance TestingAcceptance Testing

Unit TestingUnit Testing

Product ReleaseProduct Release

Component Integration Testing Component Integration Testing

A

A

A

A

A Load, Stress, performance Load, Stress, performance

Page 20: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Continuous Integration

Page 21: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Source Code

Repository

Build ServerBuild

6. R

epor

t

Code Commit Ch

ange

Trig

ger

1.

2.

3. Execute Build

CODER

Continuous Integration

Job

Report

4. Report One Commit Cycle

Page 22: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Analyzing & Unit Testing & CIAnalyzing & Unit Testing & CI

Page 23: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Code Checker

Builder

Make / AntGcc

Javac

Integration Tester

Unit Tester

Complexity Analyze

Heat Map

SourceCode

Interface Tester

Statical Analyze Dynamical Analyze

Page 24: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Source Code

Repository

Build Server

Build

Test

ReportRelease

Analyze

ReleaseBuild

Report

Code Commit

Report

Chan

ge T

rigge

rBuild Request

Build Slave

Advanced Continuous Integration

Job

Page 25: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Source Code

Repository

Build Server

Build

Test

ReportRelease

Analyze

ReleaseBuild

Report

Code Commit

Report

Chan

ge T

rigge

rBuild Request

Build Slave

Job

Page 26: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Source Code

Repository

Build Server

Build

Test

Report

Release

Analyze

Release

Build

Repo

rt

Code Commit

Report

Change Trigger

Build Slave

Build

Test

Report

Release

Analyze

Release

Build

Build Slave

Build

Test

Report

Release

Analyze

Release

Build

Build Slave

Build Request

Build Request

Build Request

Windows

Linux

Mac OS

Job

Job

Job

Job

Page 27: Unit Testing  and  Continuous Integration in context of IFDK  reference product

http://buildbot.twistedmatrix.com/waterfall

Page 28: Unit Testing  and  Continuous Integration in context of IFDK  reference product

http://en.wikipedia.org/wiki/Continuous_integration

Page 29: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Integration TestingIntegration Testing

Page 30: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Integration Test with stubsIntegration Test with stubs

Tested Component/ApplicationTested Component/Application

LogLog

STUB/MOCK ComponentSTUB/MOCK Component

Scripted STUB InterfaceScripted STUB Interface

ControlConfigureControlConfigure

SimulatedInterfaceSimulatedInterface

Messages/EventsMessages/Events

STUB/MOCK ComponentSTUB/MOCK Component

Control InterfaceControl Interface

Yläotsikko

Page 31: Unit Testing  and  Continuous Integration in context of IFDK  reference product

in practice #1 IFDK android setupin practice #1 IFDK android setup

Tested ComponentApplication

Tested ComponentApplication

Activate/ControlActivate/Control

STUB/MOCK ComponentSTUB/MOCK Component

Scripted STUB InterfaceScripted STUB Interface

ControlConfigureControlConfigure

SimulatedInterfaceSimulatedInterface

Messages/EventsMessages/Events

WEB SERVER simulatingService interfaceWEB SERVER simulatingService interface

Control InterfaceControl Interface

Trace/LogTrace/Log

Yläotsikko

Page 32: Unit Testing  and  Continuous Integration in context of IFDK  reference product

in practice #2 server component testingin practice #2 server component testing

Tested ComponentApplication

Tested ComponentApplication

Trace/LogTrace/Log

Activate/ControlActivate/Control

Mock Server/DaemonMock Server/Daemon

Scripted STUB InterfaceScripted STUB Interface

AutomatedTest Interface

AutomatedTest Interface

SimulatedInterfaceSimulatedInterface

Messages/EventsMessages/Events

WEB SERVERWEB SERVER

Control InterfaceControl Interface

Operating SystemOperating System

NeededFake Application

NeededFake Application

Junit Scripted InterfaceJunit Scripted Interface

Yläotsikko

Page 33: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Integration Testing with simulated Interfaces

FakeSpotifyServer

FakeSpotifyServer

FakeFacebook

Server

FakeFacebook

Server

SimulatedBluetoothInterface

SimulatedBluetoothInterface

SimulatedMIDI

Interface

SimulatedMIDI

Interface

Page 34: Unit Testing  and  Continuous Integration in context of IFDK  reference product

System Testing in SmallSystem Testing in Small

What should be tested?

How ?

DBDB

AppcliationAppcliation

Page 35: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Application code level testingApplication code level testing

Page 36: Unit Testing  and  Continuous Integration in context of IFDK  reference product

Yläotsikko

Page 37: Unit Testing  and  Continuous Integration in context of IFDK  reference product