Unit testingandcontinousintegrationfreenest1dot4

37

Transcript of Unit testingandcontinousintegrationfreenest1dot4

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

TESTING LEVELS

Unit/Module/Component Testing

Customer/Business Requirements

Sub System Requirements

Component Requirements

Component / Unit Testing

Integration Testing

System Testing

Acceptance Testing

System Requirements

Architecture&

Design&

Implementatio

n

Product

VALIDATION

VERIFICATION

Yläotsikko

How to Test?

What should be tested? How ?

How to verify component implementation

-Unit Testing

-Static Analyze

-Dynamic Analyze

Yläotsikko

What should be tested?

Input ?

Output?

Class Diagram

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

xUnit Framework

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

Implementation Implementation

Test Framework

Component /Unit Testing

Class

Attributes

Class

Methods

Class

Attributes

Class

Methods

Attributes

TestClass

TestMethodCall

Unit Test Frame Work

Test Method Call

Method Result

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

Implemented Class

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

Developer

Test Driven Development and Unit Testing

Class

Attributes

Class

Methods

Class

Attributes

Class

Methods

Attributes

TestClass

TestMethodCall

Unit Test Frame Work

Test Method Call

Method Result

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

Implemented Class

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

Developer

DEFINE TEST

CASES FIRST!!!

IMPLEMENT CODE

AGAINST TESTS

Ideal project team and unit testing

Implemented Software

Component #1

Implemented Software Component

#3

Implemented Software Component

#4

Implemented Software Component

#2

Software Product Integration

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 #2 Integration test engineer #1

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

?

Code 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

Code 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

Code 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

Static Code Analyze – Heat Map

Yläotsikko

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

Feature Component

Project Manager

Designer/Coder

Integration Test Engineer

Test Manager

System Testing

Feature Unit/Integration Testing

System Acceptance Testing

System Test Engineer

Test Automation Engineer

Acceptance Test Engineer

Validation

Verification

Product verification/validation and test automation

Regression Testing

Integration Testing

Functional System Testing

Acceptance Testing

Unit Testing

Product Release

Component Integration Testing

A

A

A

A

A Load, Stress, performance

Continuous Integration

Source Code

Repository

Build Server B

uild

Code Commit

1.

CODER

Continuous Integration

Job

Rep

ort

One Commit Cycle

Analyzing & Unit Testing & CI

Code Checker

Builder

Make / Ant Gcc

Javac

Integration Tester

Unit Tester

Complexity Analyze

Heat Map

Source Code

Interface Tester

Statical Analyze Dynamical Analyze

Source Code

Repository

Build Server

Bu

ild

Test

Rep

ort R

elease

An

alyze

Release

Bu

ild

Code Commit

Build Slave

Advanced Continuous Integration

Job

Source Code

Repository

Build Server

Bu

ild

Test

Rep

ort R

elease

An

alyze

Release

Bu

ild

Code Commit

Build Slave

Job

Source Code

Repository

Build Server

Bu

ild

Test

Rep

ort

Release

An

alyze

Release

Bu

ild

Code Commit

Build Slave

Bu

ild

Test

Rep

ort

Release

An

alyze

Release

Bu

ild

Build Slave

Bu

ild

Test

Rep

ort

Release

An

alyze

Release

Bu

ild

Build Slave

Windows

Linux

Mac OS

Job

Job

Job

Job

http://buildbot.twistedmatrix.com/waterfall

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

Integration Testing

Integration Test with stubs

Tested Component/Application

Log

STUB/MOCK Component

Scripted STUB Interface

Control

Configure

Simulated

Interface

Messages/Events

STUB/MOCK Component

Control Interface

Yläotsikko

in practice #1 IFDK android setup

Tested Component

Application

Activate/Control

STUB/MOCK Component

Scripted STUB Interface

Control

Configure

Simulated

Interface

Messages/Events

WEB SERVER simulating

Service interface

Control Interface

Trace/Log

Yläotsikko

in practice #2 server component testing

Tested Component

Application

Trace/Log

Activate/Control

Mock Server/Daemon

Scripted STUB Interface

Automated

Test Interface

Simulated

Interface

Messages/Events

WEB SERVER

Control Interface

Operating System

Needed

Fake Application

Junit Scripted Interface

Yläotsikko

Integration Testing with simulated Interfaces

Fake Spotify Server

Fake Facebook

Server

Simulated Bluetooth Interface

Simulated

MIDI Interface

System Testing in Small

What should be tested? How ?

DB

Appcliation

Application code level testing

Yläotsikko