You are on page 1of 41

Didik Dwi Prasetya

didikdwi@um.ac.id
Software Testing
Didik Dwi - Teknik Elektro UM
Subbahasan
Software Testing
Software Testing Strategies
Software Testing Techniques
2
Didik Dwi - Teknik Elektro UM
Software Testing
Pengujian adalah proses menjalankan
program dengan maksud untuk
menemukan kesalahan (error) sebelum di-
delivery ke pengguna.
3
(Pressman, 2009)
Didik Dwi - Teknik Elektro UM
Software Testing
Definisi lain:
Testing is the process of executing a
program or system with the intent of
finding errors (Myers, 1979)
Testing is any activity aimed at evaluating
an attribute or capability of a program or
system and determining that it meets its
required results (Hetzel, 1983)
4
Didik Dwi - Teknik Elektro UM
Software Testing Layers
Strategi: mengintegrasikan metode
perancangan kasus uji
Metode: menggunakan metode pengujian
5
Methods
Strategies
Didik Dwi - Teknik Elektro UM
Why Software Testing?
Why is it important?
To improve quality
For verification and validation (V&V)
For reliability estimation
Pengujian menghabiskan 30% - 40% dari total
effort (Pressman)
Sommerville, 1992: Development efforts are
typically distributed as follows:
Specifications / Design 30% - 40%
Implementation 15% - 30%
Testing 25% - 50%
6
Didik Dwi - Teknik Elektro UM
V & V
Verification refers to the set of tasks that ensure
that software correctly implements a specific
function.
Validation refers to a different set of tasks that
ensure that the software that has been built is
traceable to customer requirements. Boehm
[Boe81] states this another way:
Verification: "Are we building the product right?"
Validation: "Are we building the right product?"
7
Didik Dwi - Teknik Elektro UM
Testing Objectives
Pengujian adalah proses eksekusi
program dengan tujuan menemukan
kesalahan.
Kasus uji yang baik adalah yang memiliki
peluang besar menemukan as-yet-
undiscovered error.
Pengujian dikatakan berhasil bila dapat
mengungkap kesalahan yang belum
diketahui.
8
Didik Dwi - Teknik Elektro UM
Testing Principles
All tests should be traceable to customer
requirements.
Tests should be planed long before testing begins.
The Pareto principle (80-20 rule) applies to
software testing.
Testing should begin in the small and progress
toward testing in the large
Exhaustive testing is not possible
To be most effective, testing should be conducted
by an independent third party
9
Didik Dwi - Teknik Elektro UM
Terms
Mistake, error, defect, bug, fault, failure?
Mistake: aksi yang mengakibatkan
kesalahan
Error: mistake di dalam kode
Defect: error setelah delivery
Bug: defect yang diterima tim pengembang
Fault: manifestasi dari kesalahan
Failure: kegagalan akibat suatu kesalahan
10
Didik Dwi - Teknik Elektro UM
Software Testing
Software Testing Strategies
Software Testing Techniques
11
Didik Dwi - Teknik Elektro UM
Testing Strategy
12
unit test
integration
test
validation
test
system
test
SEPA 6
th
ed, Roger S. Pressman
Didik Dwi - Teknik Elektro UM
Testing Strategy
13
Unit test
I ntegration
test
Validation
test
System
test
System engineering
Requirements
Software Design
Code & I mplementation
V&V Targets
Didik Dwi - Teknik Elektro UM
Testing Strategy
We begin by testing-in-the-small and
move toward testing-in-the-large
Untuk perangkat lunak konvensional:
Fokus pada modul (komponen)
Integrasi modul
Untuk perangkat lunak OO:
Kelas modul
14
Didik Dwi - Teknik Elektro UM
Unit Testing
15
module
to be
tested
test cases
results
software
engineer
Didik Dwi - Teknik Elektro UM
Unit Testing
Module interfaces are tested for proper
information flow.
Local data are examined to ensure that
integrity is maintained.
Boundary conditions are tested.
Basis (independent) path are tested.
All error handling paths should be tested.
Drivers and/or stubs need to be developed
to test incomplete software.
16
Didik Dwi - Teknik Elektro UM
Integration Testing
17
Options:
the big bang approach
an incremental construction strategy
Didik Dwi - Teknik Elektro UM
Integration Testing
Bottom-up integration
18
drivers are replaced one at a
time, "depth first"
worker modules are grouped into
builds and integrated
A
B
C
D E
F G
cluster
Didik Dwi - Teknik Elektro UM
Integration Testing
Top-down integration
19
top module is tested with
stubs
stubs are replaced one at
a time, "depth first"
as new modules are integrated,
some subset of tests is re-run
A
B
C
D E
F G
Didik Dwi - Teknik Elektro UM
Validation Test
Focuses on visible user actions and user
recognizable outputs from the system
Validation tests are based on the use-case
scenarios
20
Didik Dwi - Teknik Elektro UM
Acceptance Testing
Making sure the software works correctly for
intended user in his or her normal work
environment.
Alpha test:
version of the complete software is tested by
customer under the supervision of the developer at
the developer's site
Beta test:
version of the complete software is tested by
customer at his or her own site without the developer
being present
21
Didik Dwi - Teknik Elektro UM
System Test
Recovery testing
check the system's ability to recover from failures
Security testing
verifies that system protection mechanism prevent
improper penetration or data alteration
Stress testing
program is checked to see how well it deals with abnormal
resource demands (i.e., quantity, frequency, or volume)
Performance testing
designed to test the run-time performance of software,
especially real-time software
22
Didik Dwi - Teknik Elektro UM
Debugging
Testing Debugging
Debugging: diagnostic process
Debugging (removal of a defect) occurs as
a consequence of successful testing.
23
Didik Dwi - Teknik Elektro UM
Software Testing
Software Testing Strategies
Software Testing Techniques
24
Didik Dwi - Teknik Elektro UM
Test Case
25
"Bugs lurk in corners
and congregate at
boundaries ..."
Boris Beizer
OBJECTIVE
CRITERIA
CONSTRAINT
to uncover errors
in a complete manner
with a minimum of effort and time
Didik Dwi - Teknik Elektro UM
Software Testing Methods
26
Methods
Strategies
white-box
methods
black-box
methods
Didik Dwi - Teknik Elektro UM
White-Box Testing
Disebut juga clear box testing, glass box
testing, transparent box testing, atau
structural testing.
Pengujian untuk memperlihatkan cara
kerja dari produk secara rinci sesuai
dengan spesifikasinya
27
Didik Dwi - Teknik Elektro UM
White-Box Testing
28
... our goal is to ensure that all
statements and conditions have
been executed at least once ...
Didik Dwi - Teknik Elektro UM
Basis Path Testing
Basis Path adalah teknik uji coba White-Box
(Tom Mc Cabe).
Basis Path: untuk mendapatkan kompleksitas
lojik dari suatu prosedur dan menggunakan
ukuran ini sebagai petunjuk untuk
mendefinisikan himpunan jalur yang akan
diuji
Cyclomatic Complexity: ukuran yang
menunjukkan kompleksitas lojik suatu
program
29
Didik Dwi - Teknik Elektro UM
Basis Path Testing
30
Didik Dwi - Teknik Elektro UM
Basis Path Testing
31
Flow graph
Didik Dwi - Teknik Elektro UM
Basis Path Testing
Predicate node
32
Didik Dwi - Teknik Elektro UM
Basis Path Testing
Cyclomatic Complexity dapat diperoleh
dengan menghitung daerah yang dapat
dibentuk oleh graph
Path 1 : 1 11
Path 2 : 1 2 3 4 5 10 1 11
Path 3 : 1 2 3 6 8 9 10 1 11
Path 4 : 1 2 3 6 7 9 10 1 11
33
Didik Dwi - Teknik Elektro UM
Basis Path Testing
Cyclomatic Complexity V(G) dapat pula
dihitung dengan
V (G) = (E N) + 2
dimana :
E = jumlah edge pada flowgraph
N = Jumlah Node pada flowgraph
Jadi, V(G) = (11 9) + 2 = 4
34
Didik Dwi - Teknik Elektro UM
Basis Path Testing
Cyclomatic Complexity juga dapat dihitung
dengan rumus :
V (G) = P + 1
dimana P = jumlah predikat Node pada flow
graph
Jadi, V (G) = 3 + 1
= 4
35
Didik Dwi - Teknik Elektro UM
Black-Box Testing
36
requirements
events
input
output
Didik Dwi - Teknik Elektro UM
Black-Box Testing
Memperlakukan software sebagai kotak
hitam
Untuk mengetahui apakah semua fungsi
perangkat lunak telah berjalan sesuai
dengan kebutuhan fungsional yang telah
didefinsikan.
37
Didik Dwi - Teknik Elektro UM
Black-Box Testing
How is system behavior and performance tested?
What classes of input will make good test cases?
Is the system particularly sensitive to certain input
values?
How is functional validity tested?
How are the boundaries of a data class isolated?
What data rates and data volume can the system
tolerate?
38
Didik Dwi - Teknik Elektro UM
Black-Box Testing
Jenis:
equivalence partitioning
boundary value analysis
all-pairs testing
fuzz testing
model-based testing
traceability matrix
exploratory testing and
specification-based testing.
39
Didik Dwi - Teknik Elektro UM
White-Box vs Black-Box
40
Operations and
Functions with I /O
White-box
interface
input
output
Internal logic, data, structure
output
input
interface
operation
Black-box
Didik Dwi - Teknik Elektro UM
Conclusion
Pengujian adalah proses menjalankan
program dengan maksud untuk
menemukan kesalahan (error) sebelum di-
delivery ke pengguna.
Layer/aktivitas: metode dan strategi
Metode pengujian:
White-Box Testing
Black-Box Testing
41