SlideShare a Scribd company logo
1 of 54
1
Cyclomatic Complexity
2
What is it?
 A software metric used to measure the complexity
of software
 Developed by Thomas McCabe
 Described (informally) as the number of decision
points + 1
Cyclomatic Complexity V(G)
Computing the cyclomatic
complexity:
number of simple decisions + 1
or
number of enclosed areas + 1
In this case, V(G) = 4
From Pressman Slides - Software Engineering a Practical Approach 6,e
Graph Complexity
(Cyclomatic Complexity)
A number of industry studies have indicated
that the higher V(G), the higher the probability
or errors.
V(G)
modules
modules in this range are
more error prone
From Pressman Slides - Software Engineering a Practical Approach 6,e
Basis Path Testing
Next, we derive the
independent paths:
Since V(G) = 4,
there are four paths
Path 1: 1,2,3,6,7,8
Path 2: 1,2,3,5,7,8
Path 3: 1,2,4,7,8
Path 4: 1,2,4,7,2,4,...7,8
Finally, we derive test
cases to exercise these
paths.
1
2
3
4
5 6
7
8
From Pressman Slides - Software Engineering a Practical Approach 6,e
What is the complexity?
public void howComplex() {
int i=20;
while (i<10) {
System.out.printf("i is %d", i);
if (i%2 == 0) {
System.out.println("even");
} else {
System.out.println("odd");
}
}
}
What is the complexity V(G)?
public void howComplex() {
int i=20;
while (i<10) {
System.out.printf("i is %d", i);
if (i%2 == 0) {
System.out.println("even");
} else {
System.out.println("odd");
}
}
}
V(G) = 2 enclosed area + 1 = 3
Output from JavaNCSS
Cyclomatic Complexity
10
 Invented by Thomas McCabe (1974) to measure the
complexity of a program’s conditional logic
 Cyclomatic complexity of graph G equals #edges -
#nodes + 2
 V(G) = e – n + 2
 Also corresponds to the number of linearly
independent paths in a program
Converting Code to Graph
11
if expression1 then
statement2
else
statement3
end if
statement4
switch expr1
case 1:
statement2
case 2:
statm3
case 3:
statm4
end switch
statm5
(a)
(b)
do
statement1
while expr2
end do
statement3
(c)
CODE FLOWCHART GRAPH
T F
expr1
?
statm4
statm2 statm3
2
1 3
expr1
?
statm5
statm3
statm2 statm4
n1
n2 n3
n4
n1
n2 n4
n5
n3
T
F
expr2
?
statm3
statm1
n1
n2
n3
Example Paths
12
if expression1
then
statement2
end if
do
statement3
while expr4
end do
if expression5
then
statement6
end if
statement7
n1
n3
n2
n4
n5
n7
n6
e1
e2
e3
e4 e5
e6
e7
e8
e9
Paths:
P1 = e1, e2, e4, e6, e7, e8
P2 = e1, e2, e4, e5, e4, e6, e7, e8
P3 = e3, e4, e6, e7, e8, e10
P4 = e6, e7, e8, e10, e3, e4
P5 = e1, e2, e4, e6, e9, e10
P6 = e4, e5
P7 = e3, e4, e6, e9, e10
P8 = e1, e2, e4, e5, e4, e6, e9, e10
V(G) = e – n + 2 = 9 – 7 + 2 = 4
Example 1
13
14
V=e-n+2=11-9+2=4
15
16
V=e-n+2=11-9+2=4
• The testing process
• Determining the test methodology phase
• Planning the tests
• Test design
• Test implementation
• Test case design
• Test case data components
• Test case sources
• Automated testing
• The process of automated testing
• Types of automated testing
• Advantages and disadvantages of automated testing
• Alpha and beta site testing programs
Chapter 10 – Software Testing -
Implementation
Introduction
 Need to discuss
 testing effectiveness and
 testing efficiency.
 Equivalently, want to reduce number of undetected
errors and yet test with fewer resources over less
time.
 Need to design testing procedures to be effective in
detecting errors and doing so as efficiently as
possible.
 Also want to look at automatic testing too.
Introduction – Topics to Cover
 Much of this set of slides focuses on testing at
various levels:
 Unit tests
 Integration tests
 System tests.
Ultimate Desired Outcomes for the
Chapter
 Today:
 Describe the process of planning and designing
tests
 Discuss the sources for test cases, with their
advantages and disadvantages
 Next:
 List the main types of automated software tests
 Discuss the advantages and disadvantages of
automated computerized testing as compared to
manual testing
 Explain alpha and beta site test implementation and
discuss their advantages and disadvantages.
10.1 The Testing Process
 Testing is done throughout the development
process.
 Testing is divided into phases beginning in the
design phase and ending at the customer’s site.
 Testing process is illustrated in the next slide.
 The two fundamental decisions that must be made
before planning for testing can occur are:
 What is the required software quality standard, and
 What is the software testing strategy.
Determining the test
methodology
Planning the tests
Designing the tests
Performing the tests
(implementation)
Determining the Appropriate
Software Quality Standard
 Different standards required for different software
applications.
 e.g. safety-critical software or aircraft instrumentation -
critical.
 In other cases, a medium-level quality would be sufficient,
and
 So, the expected damage resulting from failed software
impacts standard of software quality.
 Samples of damage to customers and users as well as to
1. Endangers the safety of human beings
2. Affects an essential organizational function with no system
replacement capability available
3. Affects functioning of firmware, causing malfunction of an
entire system
4. Affects an essential organizational function but a replacement
is available
5. Affects proper functioning of software packages for business
applications
6. Affects proper functioning of software packages for a private
customer
7. Affects functioning of a firmware application but without
affecting the entire system.
8. Inconveniences the user but does not prevent accomplishment
of the system’s capabilities
1. Financial losses
* Damages paid for physical injuries
Aircraft or auto instrumentation; health equipment…. Law suites!!
* Damages paid to organizations for malfunctioning of
software
Companies have many lawyers on staff!!!
* Purchase cost reimbursed to customers
* High maintenance expenses for repair of failed systems
2. Non-quantitative damages
* Expected to affect future sales
* Substantially reduced current sales
Determining Software Testing Strategy
 Big Bank or Incremental? So, do we want the
testing strategy to be big bang or incremental?
 Major testing at end in the past….
 If incremental, top down or bottom up?
 Which parts of the testing plan should be done
using white box testing?
 Black box?
 Which parts of the test plan should be done using
an automated test model?
Planning the Tests
 We need to undertake:
 Unit tests
 Integration tests, and
 System Tests.
 Unit tests deal with small chunks – modules,
functions, objects, classes;
 Integration tests deal with units constituting a
subsystem or other major hunks of capability, and
 System tests refer to the entire software
package or system.
 These are often done by different
constitutencies!!
Lots of Questions
 So we first need to consider five basic issues:
 What to test
 Which sources do we use for test cases
 Who is to perform the tests
 Where to perform the tests, and
 When to terminate the tests.
 Questions with not so obvious answers!
What to Test
 We would like to test everything.
 Not very practical.
 Cannot undertake exhaustive testing…
 Number of paths is infinite….
 Consider:
 Do we totally test modules that are 98% reused?
 Do we really need to test things that have been
repeatedly tested with only slight changes?
 How about testing by newbees?
 Testing on sensitive modules that pose lots of risk?
 So, which modules need to be unit tested?
 Which integrations should be tested?
 Maybe low priority applications tested in unit
testing may not be needed or included in the
system tests….
 Lots of planning is needed, as testing IS a very
expensive undertaking!
Rating Units, Integrations, and
Applications
 We need to rate these issues to determine their
priority in the testing plan.
 Rate based on two factors:
 1. Damage severity level – severity of results if
module / application fails.
 How much damage is done??
 Will it destroy our business? Our reputation??
 2. Software risk level – what is the probability
of failure.
 Factors affecting risk – next slide:
Module/Application Issues
1. Magnitude (size)
2. Complexity and difficulty
3. Percentage of original software (vs. percentage of
reused software)
Programmer Issues
4. Professional qualifications
5. Experience with the module's specific subject matter.
6. Availability of professional support (backup of
knowledgeable and experience).
7. Acquaintance with the programmer and the ability to
evaluate his/her capabilities.
Computations
 Essential to calculate risk levels
 We must budget our testing due to high cost
 But we must temper our testing with cost/risk!
 Helps to determine what to test and to what
extent.
 Use a ‘combined’ rating bringing together
damage severity (how serious would the damage
be?) and risk severity / probability.
 Sample calculations: A is damage; B is risk.
 C = A + B
 C = k*A + m * B
 C = A * B // most familiar with this one…
 If we are including unit, integration, and applications in a
test plan, we need to know how much/many resources
are needed.
 Thus, we need to prioritize.
 Higher the rating, and priority more allocation of
testing resources are needed.
 Consider:
 Some tests are based on high percentages of reused code.
 Some applications are developed by new employees
 We typically use a 5 point scale, where 5 is high.
 (Variations include a 1-5 severity level and a probability of
0.0 to 1.0 of their occurrence.)
 Can see results for Super Teacher application in next
slide.
Combined rating method
Application Damage
Severity
Factor A
Damage
Severity
Factor B
A +B 7xA+2xB A x B
1. Input of test results 3 2 5 (4) 25 (5) 6 (4)
2. Interface for input and output of pupils’data to
and from other teachers
4 4 8 (1) 36 (1) 16 (1)
3. Preparation of lists of low achievers 2 2 4 (5-6) 18 (7) 4 (5-6)
4. Printing letters to parents of low achievers 1 2 3 (7-8) 11 (8) 2 (8)
5. Preparation of reports for the school principal 3 3 6 (3) 27 (3) 9 (3)
6. Display of a pupil’s achievements profile 4 3 7 (2) 34 (2) 12 (2)
7. Printing of pupil’s term report card 3 1 3 (7-8) 23 (6) 3 (7)
8. Printing of pupil’s year-end report card 4 1 4 (5-6) 26 (4) 4 (5-6)
(Damage / p())
1. Which Sources Should be Used for
Test Cases?
 Do we use live test cases or synthetic test cases.
 All three types of tests should consider these.
 Use live data or contrived (dummy) data??
 What do you think??
 Also need to consider single / combined tests and
the number of tests.
 How about if the testing is top down? Bottom up?
What sources do you think might be needed then??
Who Performs the Tests?
 Unit Testing – done by the programmer and/or
development team.
 Integration Testing – can be the development team
or a testing unit.
 System Testing – usually done by an independent
testing team (internal or external (consultants) team.
 For small companies, another testing team from
another development team can be used and swapped.
 Can always outsource testing too.
Where to Perform the Tests?
 Typically at the software developer’s site..
 For system tests, test at developer’s or
customer’s site (target site).
 If outsourced, testing can be done at
consultant’s site.
When are Tests Terminated?
 This is always the $64,000 question!!
 Decision normally applies to system tests.
 Five typical alternatives
 1. Completed Implementation Route
 Test until all is error free. (good luck)
 All testing, regression testing;
 Disregards budget and timetable constraints.
 Applies to perfection approach
 2. Mathematical Models Application Route:
 Here modeling us used to estimate percentage of
undetected errors based on rate of error detection.
 When detection rate falls below a certain level, stop.
 Disadvantage: math model may not fully represent
the project’s characteristics.
 Thus testing may be cut short or extended too far.
 Advantage: Well-defined stopping point.
 3. Error Seeding Route
 Here, we seed errors prior to testing.
 Underlying assumption is that percentage of
discovered seeded errors will correspond to the
percentage of real errors detected.
 Stop once residual percentage of undetected
seeded errors reaches a predefined level considered
acceptable for ‘passing’ the system.
 Disadvantages: extra workload for testers; also
based on past experiences of some testers;
 Too, seeding method can not accurately estimate
the residual rate of undetected errors in unfamiliar
systems.
 4. The dual independent testing teams route:
 Here two teams implement the testing process
independently.
 Compare lists of detected errors.
 Calculate the number of errors left undetected
 Lots of statistics here.
 High costs. Justified when??
 5. Termination after resources have petered out.
 This means stop when budgets or time for testing has
run out.
 Very common in industry
Test Plan
 Lastly, system testing is documented in a
software test plan.
 Common formats are available.
Test Design and Software Test Plan
 Products of Test Design
 Detailed design and procedures for each test
 The input database / files for testing.
 There are standard software test plans (STP)
templates
1 Scope of the tests
1.1 The software package to be tested (name, version and
revision)
1.2 The documents that provide the basis for the planned
tests
2 Testing environment
2.1 Sites
2.2 Required hardware and firmware configuration
2.3 Participating organizations
2.4 Manpower requirements
2.5 Preparation and training required of the test team
3 Tests details (for each test)
3.1 Test identification
3.2 Test objective
3.3 Cross-reference to the relevant design document and the
requirement document
3.4 Test class
3.5 Test level (unit, integration or system tests)
3.6 Test case requirements
3.7 Special requirements (e.g., measurements of response times,
security requirements)
3.8 Data to be recorded
4 Test schedule (for each test or test group) including time
estimates for:
4.1 Preparation
4.2 Testing
4.3 Error correction
4.4 Regression tests
1 Scope of the tests
1.1 The software package to be tested (name, version
and revision)
1.2 The documents providing the basis for the designed
tests (name and
version for each document)
2 Test environment (for each test)
2.1 Test identification (the test details are documented
in the STP)
2.2 Detailed description of the operating system and
hardware configuration
and the required switch settings for the tests
2.3 Instructions for software loading
3. Testing process
3.1 Instructions for input, detailing every step of the
input process
3.2 Data to be recorded during the tests
4.Test cases (for each case)
4.1 Test case identification details
4.2 Input data and system settings
4.3 Expected intermediate results (if applicable)
4.4 Expected results (numerical, message, activation of
equipment, etc.)
5. Actions to be taken in case of program
failure/cessation
6. Procedures to be applied according to the test
Test Implementation
 Really, this is just running the tests, correction of
tests, running regression tests,
 Testing is done when the outcomes satisfy the
developers.
 When are these tests run?? (time of day/ date??)
Regression Testing
 Need not test everything.
 Typically re-test only those artifacts directly changed
and those providing inputs and outputs to these
changed artifacts (modules).
 Very often new errors are introduced when changes
are made.
 There’s always risk in not testing everything… but
these decisions must be made.
 Results of testing are documented in a test report.
1. Test identification, site, schedule and participation
1.1 The tested software identification (name, version and
revision)
1.2 The documents providing the basis for the tests (name and
version for each document)
1.3 Test site
1.4 Initiation and concluding times for each testing session
1.5 Test team members
1.6 Other participants
1.7 Hours invested in performing the tests
2. Test environment
2.1 Hardware and firmware configurations
2.2 Preparations and training prior to testing
3. Test results
3.1 Test identification
3.2 Test case results (for each test case individually)
4. Summary tables for total number of errors, their
distribution and types
4.1 Summary of current tests
4.2 Comparison with previous results (for regression test summaries)
5. Special events and testers' proposals
5.1 Special events and unpredicted responses of the software during testing
5.2 Problems encountered during testing.
5.3 Proposals for changes in the test environment, including test preparations
5.4 Proposals for changes or corrections in test procedures and test case files

More Related Content

Similar to SE-CyclomaticComplexityand Testing.ppt

Testing Software Solutions
Testing Software SolutionsTesting Software Solutions
Testing Software Solutions
gavhays
 
software testing types jxnvlbnLCBNFVjnl/fknblb
software testing types jxnvlbnLCBNFVjnl/fknblbsoftware testing types jxnvlbnLCBNFVjnl/fknblb
software testing types jxnvlbnLCBNFVjnl/fknblb
jeyasrig
 
ISTQB / ISEB Foundation Exam Practice -1
ISTQB / ISEB Foundation Exam Practice -1ISTQB / ISEB Foundation Exam Practice -1
ISTQB / ISEB Foundation Exam Practice -1
Yogindernath Gupta
 
Software testing
Software testingSoftware testing
Software testing
Bala Ganesh
 

Similar to SE-CyclomaticComplexityand Testing.ppt (20)

Software Testing Introduction (Part 1)
Software Testing Introduction (Part 1)Software Testing Introduction (Part 1)
Software Testing Introduction (Part 1)
 
Testing Software Solutions
Testing Software SolutionsTesting Software Solutions
Testing Software Solutions
 
software testing types jxnvlbnLCBNFVjnl/fknblb
software testing types jxnvlbnLCBNFVjnl/fknblbsoftware testing types jxnvlbnLCBNFVjnl/fknblb
software testing types jxnvlbnLCBNFVjnl/fknblb
 
ISTQB / ISEB Foundation Exam Practice -1
ISTQB / ISEB Foundation Exam Practice -1ISTQB / ISEB Foundation Exam Practice -1
ISTQB / ISEB Foundation Exam Practice -1
 
Some Commonly Asked Question For Software Testing
Some Commonly Asked Question For Software TestingSome Commonly Asked Question For Software Testing
Some Commonly Asked Question For Software Testing
 
ISTQB, ISEB Lecture Notes
ISTQB, ISEB Lecture NotesISTQB, ISEB Lecture Notes
ISTQB, ISEB Lecture Notes
 
Software testing for biginners
Software testing for biginnersSoftware testing for biginners
Software testing for biginners
 
Slides chapters 13-14
Slides chapters 13-14Slides chapters 13-14
Slides chapters 13-14
 
Testing
TestingTesting
Testing
 
Testing Interview Questions.pdf
Testing Interview Questions.pdfTesting Interview Questions.pdf
Testing Interview Questions.pdf
 
Software testing introduction
Software testing introductionSoftware testing introduction
Software testing introduction
 
ISTQB, ISEB Lecture Notes- 2
ISTQB, ISEB Lecture Notes- 2ISTQB, ISEB Lecture Notes- 2
ISTQB, ISEB Lecture Notes- 2
 
Testing methodology
Testing methodologyTesting methodology
Testing methodology
 
Testing software development
Testing software developmentTesting software development
Testing software development
 
Fundamentals of Testing
Fundamentals of TestingFundamentals of Testing
Fundamentals of Testing
 
Testing Fundamentals
Testing FundamentalsTesting Fundamentals
Testing Fundamentals
 
Test design techniques: Structured and Experienced-based techniques
Test design techniques: Structured and Experienced-based techniquesTest design techniques: Structured and Experienced-based techniques
Test design techniques: Structured and Experienced-based techniques
 
Testing concepts [3] - Software Testing Techniques (CIS640)
Testing concepts [3] - Software Testing Techniques (CIS640)Testing concepts [3] - Software Testing Techniques (CIS640)
Testing concepts [3] - Software Testing Techniques (CIS640)
 
SOFTWARE QUALITY ASSURANCE AND TESTING - SHORT NOTES
SOFTWARE QUALITY ASSURANCE AND TESTING - SHORT NOTESSOFTWARE QUALITY ASSURANCE AND TESTING - SHORT NOTES
SOFTWARE QUALITY ASSURANCE AND TESTING - SHORT NOTES
 
Software testing
Software testingSoftware testing
Software testing
 

More from vishal choudhary

More from vishal choudhary (20)

SE-Lecture1.ppt
SE-Lecture1.pptSE-Lecture1.ppt
SE-Lecture1.ppt
 
SE-Testing.ppt
SE-Testing.pptSE-Testing.ppt
SE-Testing.ppt
 
SE-Lecture-7.pptx
SE-Lecture-7.pptxSE-Lecture-7.pptx
SE-Lecture-7.pptx
 
Se-Lecture-6.ppt
Se-Lecture-6.pptSe-Lecture-6.ppt
Se-Lecture-6.ppt
 
SE-Lecture-5.pptx
SE-Lecture-5.pptxSE-Lecture-5.pptx
SE-Lecture-5.pptx
 
XML.pptx
XML.pptxXML.pptx
XML.pptx
 
SE-Lecture-8.pptx
SE-Lecture-8.pptxSE-Lecture-8.pptx
SE-Lecture-8.pptx
 
SE-coupling and cohesion.ppt
SE-coupling and cohesion.pptSE-coupling and cohesion.ppt
SE-coupling and cohesion.ppt
 
SE-Lecture-2.pptx
SE-Lecture-2.pptxSE-Lecture-2.pptx
SE-Lecture-2.pptx
 
SE-software design.ppt
SE-software design.pptSE-software design.ppt
SE-software design.ppt
 
SE1.ppt
SE1.pptSE1.ppt
SE1.ppt
 
SE-Lecture-4.pptx
SE-Lecture-4.pptxSE-Lecture-4.pptx
SE-Lecture-4.pptx
 
SE-Lecture=3.pptx
SE-Lecture=3.pptxSE-Lecture=3.pptx
SE-Lecture=3.pptx
 
Multimedia-Lecture-Animation.pptx
Multimedia-Lecture-Animation.pptxMultimedia-Lecture-Animation.pptx
Multimedia-Lecture-Animation.pptx
 
MultimediaLecture5.pptx
MultimediaLecture5.pptxMultimediaLecture5.pptx
MultimediaLecture5.pptx
 
Multimedia-Lecture-7.pptx
Multimedia-Lecture-7.pptxMultimedia-Lecture-7.pptx
Multimedia-Lecture-7.pptx
 
MultiMedia-Lecture-4.pptx
MultiMedia-Lecture-4.pptxMultiMedia-Lecture-4.pptx
MultiMedia-Lecture-4.pptx
 
Multimedia-Lecture-6.pptx
Multimedia-Lecture-6.pptxMultimedia-Lecture-6.pptx
Multimedia-Lecture-6.pptx
 
Multimedia-Lecture-3.pptx
Multimedia-Lecture-3.pptxMultimedia-Lecture-3.pptx
Multimedia-Lecture-3.pptx
 
Multimedia-Lecture-1.pptx
Multimedia-Lecture-1.pptxMultimedia-Lecture-1.pptx
Multimedia-Lecture-1.pptx
 

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 

Recently uploaded (20)

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdfOur Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food Additives
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 

SE-CyclomaticComplexityand Testing.ppt

  • 2. 2
  • 3. What is it?  A software metric used to measure the complexity of software  Developed by Thomas McCabe  Described (informally) as the number of decision points + 1
  • 4. Cyclomatic Complexity V(G) Computing the cyclomatic complexity: number of simple decisions + 1 or number of enclosed areas + 1 In this case, V(G) = 4 From Pressman Slides - Software Engineering a Practical Approach 6,e
  • 5. Graph Complexity (Cyclomatic Complexity) A number of industry studies have indicated that the higher V(G), the higher the probability or errors. V(G) modules modules in this range are more error prone From Pressman Slides - Software Engineering a Practical Approach 6,e
  • 6. Basis Path Testing Next, we derive the independent paths: Since V(G) = 4, there are four paths Path 1: 1,2,3,6,7,8 Path 2: 1,2,3,5,7,8 Path 3: 1,2,4,7,8 Path 4: 1,2,4,7,2,4,...7,8 Finally, we derive test cases to exercise these paths. 1 2 3 4 5 6 7 8 From Pressman Slides - Software Engineering a Practical Approach 6,e
  • 7. What is the complexity? public void howComplex() { int i=20; while (i<10) { System.out.printf("i is %d", i); if (i%2 == 0) { System.out.println("even"); } else { System.out.println("odd"); } } }
  • 8. What is the complexity V(G)? public void howComplex() { int i=20; while (i<10) { System.out.printf("i is %d", i); if (i%2 == 0) { System.out.println("even"); } else { System.out.println("odd"); } } } V(G) = 2 enclosed area + 1 = 3
  • 10. Cyclomatic Complexity 10  Invented by Thomas McCabe (1974) to measure the complexity of a program’s conditional logic  Cyclomatic complexity of graph G equals #edges - #nodes + 2  V(G) = e – n + 2  Also corresponds to the number of linearly independent paths in a program
  • 11. Converting Code to Graph 11 if expression1 then statement2 else statement3 end if statement4 switch expr1 case 1: statement2 case 2: statm3 case 3: statm4 end switch statm5 (a) (b) do statement1 while expr2 end do statement3 (c) CODE FLOWCHART GRAPH T F expr1 ? statm4 statm2 statm3 2 1 3 expr1 ? statm5 statm3 statm2 statm4 n1 n2 n3 n4 n1 n2 n4 n5 n3 T F expr2 ? statm3 statm1 n1 n2 n3
  • 12. Example Paths 12 if expression1 then statement2 end if do statement3 while expr4 end do if expression5 then statement6 end if statement7 n1 n3 n2 n4 n5 n7 n6 e1 e2 e3 e4 e5 e6 e7 e8 e9 Paths: P1 = e1, e2, e4, e6, e7, e8 P2 = e1, e2, e4, e5, e4, e6, e7, e8 P3 = e3, e4, e6, e7, e8, e10 P4 = e6, e7, e8, e10, e3, e4 P5 = e1, e2, e4, e6, e9, e10 P6 = e4, e5 P7 = e3, e4, e6, e9, e10 P8 = e1, e2, e4, e5, e4, e6, e9, e10 V(G) = e – n + 2 = 9 – 7 + 2 = 4
  • 15. 15
  • 17. • The testing process • Determining the test methodology phase • Planning the tests • Test design • Test implementation • Test case design • Test case data components • Test case sources • Automated testing • The process of automated testing • Types of automated testing • Advantages and disadvantages of automated testing • Alpha and beta site testing programs Chapter 10 – Software Testing - Implementation
  • 18. Introduction  Need to discuss  testing effectiveness and  testing efficiency.  Equivalently, want to reduce number of undetected errors and yet test with fewer resources over less time.  Need to design testing procedures to be effective in detecting errors and doing so as efficiently as possible.  Also want to look at automatic testing too.
  • 19. Introduction – Topics to Cover  Much of this set of slides focuses on testing at various levels:  Unit tests  Integration tests  System tests.
  • 20. Ultimate Desired Outcomes for the Chapter  Today:  Describe the process of planning and designing tests  Discuss the sources for test cases, with their advantages and disadvantages  Next:  List the main types of automated software tests  Discuss the advantages and disadvantages of automated computerized testing as compared to manual testing  Explain alpha and beta site test implementation and discuss their advantages and disadvantages.
  • 21. 10.1 The Testing Process  Testing is done throughout the development process.  Testing is divided into phases beginning in the design phase and ending at the customer’s site.  Testing process is illustrated in the next slide.  The two fundamental decisions that must be made before planning for testing can occur are:  What is the required software quality standard, and  What is the software testing strategy.
  • 22. Determining the test methodology Planning the tests Designing the tests Performing the tests (implementation)
  • 23. Determining the Appropriate Software Quality Standard  Different standards required for different software applications.  e.g. safety-critical software or aircraft instrumentation - critical.  In other cases, a medium-level quality would be sufficient, and  So, the expected damage resulting from failed software impacts standard of software quality.  Samples of damage to customers and users as well as to
  • 24. 1. Endangers the safety of human beings 2. Affects an essential organizational function with no system replacement capability available 3. Affects functioning of firmware, causing malfunction of an entire system 4. Affects an essential organizational function but a replacement is available 5. Affects proper functioning of software packages for business applications 6. Affects proper functioning of software packages for a private customer 7. Affects functioning of a firmware application but without affecting the entire system. 8. Inconveniences the user but does not prevent accomplishment of the system’s capabilities
  • 25. 1. Financial losses * Damages paid for physical injuries Aircraft or auto instrumentation; health equipment…. Law suites!! * Damages paid to organizations for malfunctioning of software Companies have many lawyers on staff!!! * Purchase cost reimbursed to customers * High maintenance expenses for repair of failed systems 2. Non-quantitative damages * Expected to affect future sales * Substantially reduced current sales
  • 26. Determining Software Testing Strategy  Big Bank or Incremental? So, do we want the testing strategy to be big bang or incremental?  Major testing at end in the past….  If incremental, top down or bottom up?  Which parts of the testing plan should be done using white box testing?  Black box?  Which parts of the test plan should be done using an automated test model?
  • 27. Planning the Tests  We need to undertake:  Unit tests  Integration tests, and  System Tests.  Unit tests deal with small chunks – modules, functions, objects, classes;  Integration tests deal with units constituting a subsystem or other major hunks of capability, and  System tests refer to the entire software package or system.  These are often done by different constitutencies!!
  • 28. Lots of Questions  So we first need to consider five basic issues:  What to test  Which sources do we use for test cases  Who is to perform the tests  Where to perform the tests, and  When to terminate the tests.  Questions with not so obvious answers!
  • 29. What to Test  We would like to test everything.  Not very practical.  Cannot undertake exhaustive testing…  Number of paths is infinite….  Consider:  Do we totally test modules that are 98% reused?  Do we really need to test things that have been repeatedly tested with only slight changes?  How about testing by newbees?  Testing on sensitive modules that pose lots of risk?
  • 30.  So, which modules need to be unit tested?  Which integrations should be tested?  Maybe low priority applications tested in unit testing may not be needed or included in the system tests….  Lots of planning is needed, as testing IS a very expensive undertaking!
  • 31. Rating Units, Integrations, and Applications  We need to rate these issues to determine their priority in the testing plan.  Rate based on two factors:  1. Damage severity level – severity of results if module / application fails.  How much damage is done??  Will it destroy our business? Our reputation??  2. Software risk level – what is the probability of failure.  Factors affecting risk – next slide:
  • 32. Module/Application Issues 1. Magnitude (size) 2. Complexity and difficulty 3. Percentage of original software (vs. percentage of reused software) Programmer Issues 4. Professional qualifications 5. Experience with the module's specific subject matter. 6. Availability of professional support (backup of knowledgeable and experience). 7. Acquaintance with the programmer and the ability to evaluate his/her capabilities.
  • 33. Computations  Essential to calculate risk levels  We must budget our testing due to high cost  But we must temper our testing with cost/risk!  Helps to determine what to test and to what extent.  Use a ‘combined’ rating bringing together damage severity (how serious would the damage be?) and risk severity / probability.  Sample calculations: A is damage; B is risk.  C = A + B  C = k*A + m * B  C = A * B // most familiar with this one…
  • 34.  If we are including unit, integration, and applications in a test plan, we need to know how much/many resources are needed.  Thus, we need to prioritize.  Higher the rating, and priority more allocation of testing resources are needed.  Consider:  Some tests are based on high percentages of reused code.  Some applications are developed by new employees  We typically use a 5 point scale, where 5 is high.  (Variations include a 1-5 severity level and a probability of 0.0 to 1.0 of their occurrence.)  Can see results for Super Teacher application in next slide.
  • 35. Combined rating method Application Damage Severity Factor A Damage Severity Factor B A +B 7xA+2xB A x B 1. Input of test results 3 2 5 (4) 25 (5) 6 (4) 2. Interface for input and output of pupils’data to and from other teachers 4 4 8 (1) 36 (1) 16 (1) 3. Preparation of lists of low achievers 2 2 4 (5-6) 18 (7) 4 (5-6) 4. Printing letters to parents of low achievers 1 2 3 (7-8) 11 (8) 2 (8) 5. Preparation of reports for the school principal 3 3 6 (3) 27 (3) 9 (3) 6. Display of a pupil’s achievements profile 4 3 7 (2) 34 (2) 12 (2) 7. Printing of pupil’s term report card 3 1 3 (7-8) 23 (6) 3 (7) 8. Printing of pupil’s year-end report card 4 1 4 (5-6) 26 (4) 4 (5-6) (Damage / p())
  • 36. 1. Which Sources Should be Used for Test Cases?  Do we use live test cases or synthetic test cases.  All three types of tests should consider these.  Use live data or contrived (dummy) data??  What do you think??  Also need to consider single / combined tests and the number of tests.  How about if the testing is top down? Bottom up? What sources do you think might be needed then??
  • 37. Who Performs the Tests?  Unit Testing – done by the programmer and/or development team.  Integration Testing – can be the development team or a testing unit.  System Testing – usually done by an independent testing team (internal or external (consultants) team.  For small companies, another testing team from another development team can be used and swapped.  Can always outsource testing too.
  • 38. Where to Perform the Tests?  Typically at the software developer’s site..  For system tests, test at developer’s or customer’s site (target site).  If outsourced, testing can be done at consultant’s site.
  • 39. When are Tests Terminated?  This is always the $64,000 question!!  Decision normally applies to system tests.  Five typical alternatives  1. Completed Implementation Route  Test until all is error free. (good luck)  All testing, regression testing;  Disregards budget and timetable constraints.  Applies to perfection approach
  • 40.  2. Mathematical Models Application Route:  Here modeling us used to estimate percentage of undetected errors based on rate of error detection.  When detection rate falls below a certain level, stop.  Disadvantage: math model may not fully represent the project’s characteristics.  Thus testing may be cut short or extended too far.  Advantage: Well-defined stopping point.
  • 41.  3. Error Seeding Route  Here, we seed errors prior to testing.  Underlying assumption is that percentage of discovered seeded errors will correspond to the percentage of real errors detected.  Stop once residual percentage of undetected seeded errors reaches a predefined level considered acceptable for ‘passing’ the system.  Disadvantages: extra workload for testers; also based on past experiences of some testers;  Too, seeding method can not accurately estimate the residual rate of undetected errors in unfamiliar systems.
  • 42.  4. The dual independent testing teams route:  Here two teams implement the testing process independently.  Compare lists of detected errors.  Calculate the number of errors left undetected  Lots of statistics here.  High costs. Justified when??
  • 43.  5. Termination after resources have petered out.  This means stop when budgets or time for testing has run out.  Very common in industry
  • 44. Test Plan  Lastly, system testing is documented in a software test plan.  Common formats are available.
  • 45. Test Design and Software Test Plan  Products of Test Design  Detailed design and procedures for each test  The input database / files for testing.  There are standard software test plans (STP) templates
  • 46. 1 Scope of the tests 1.1 The software package to be tested (name, version and revision) 1.2 The documents that provide the basis for the planned tests 2 Testing environment 2.1 Sites 2.2 Required hardware and firmware configuration 2.3 Participating organizations 2.4 Manpower requirements 2.5 Preparation and training required of the test team
  • 47. 3 Tests details (for each test) 3.1 Test identification 3.2 Test objective 3.3 Cross-reference to the relevant design document and the requirement document 3.4 Test class 3.5 Test level (unit, integration or system tests) 3.6 Test case requirements 3.7 Special requirements (e.g., measurements of response times, security requirements) 3.8 Data to be recorded 4 Test schedule (for each test or test group) including time estimates for: 4.1 Preparation 4.2 Testing 4.3 Error correction 4.4 Regression tests
  • 48. 1 Scope of the tests 1.1 The software package to be tested (name, version and revision) 1.2 The documents providing the basis for the designed tests (name and version for each document) 2 Test environment (for each test) 2.1 Test identification (the test details are documented in the STP) 2.2 Detailed description of the operating system and hardware configuration and the required switch settings for the tests 2.3 Instructions for software loading
  • 49. 3. Testing process 3.1 Instructions for input, detailing every step of the input process 3.2 Data to be recorded during the tests 4.Test cases (for each case) 4.1 Test case identification details 4.2 Input data and system settings 4.3 Expected intermediate results (if applicable) 4.4 Expected results (numerical, message, activation of equipment, etc.) 5. Actions to be taken in case of program failure/cessation 6. Procedures to be applied according to the test
  • 50. Test Implementation  Really, this is just running the tests, correction of tests, running regression tests,  Testing is done when the outcomes satisfy the developers.  When are these tests run?? (time of day/ date??)
  • 51. Regression Testing  Need not test everything.  Typically re-test only those artifacts directly changed and those providing inputs and outputs to these changed artifacts (modules).  Very often new errors are introduced when changes are made.  There’s always risk in not testing everything… but these decisions must be made.  Results of testing are documented in a test report.
  • 52.
  • 53. 1. Test identification, site, schedule and participation 1.1 The tested software identification (name, version and revision) 1.2 The documents providing the basis for the tests (name and version for each document) 1.3 Test site 1.4 Initiation and concluding times for each testing session 1.5 Test team members 1.6 Other participants 1.7 Hours invested in performing the tests 2. Test environment 2.1 Hardware and firmware configurations 2.2 Preparations and training prior to testing
  • 54. 3. Test results 3.1 Test identification 3.2 Test case results (for each test case individually) 4. Summary tables for total number of errors, their distribution and types 4.1 Summary of current tests 4.2 Comparison with previous results (for regression test summaries) 5. Special events and testers' proposals 5.1 Special events and unpredicted responses of the software during testing 5.2 Problems encountered during testing. 5.3 Proposals for changes in the test environment, including test preparations 5.4 Proposals for changes or corrections in test procedures and test case files