Lecture 12 - Software Testing (v.1)
Lecture 12 - Software Testing (v.1)
❖ Design Patterns
❖ Software Architecture
2
Software Design and Implementation
❖ Process to convert system specification into an executable
❖ Software design
○ Design a software structure that realizes the specification;
■ Design Principles
■ Design Patterns
■ Software Architecture
❖ Implementation
○ Translate this structure into an executable program;
Design &
Specification Validation Evolution
Implementation
❖ Validation:
"Are we building the right product”.
○ The software should do what the user really requires.
5
Verification and Validation: Example
❖ Verification Example: Imagine a team is developing a
new mobile banking app. During the verification phase,
they review the requirements and design documents.
They check if all the specified features like fund transfer,
account balance check, and transaction history are
included and correctly detailed in the design. They also
perform peer reviews and inspections to ensure the
design aligns with the requirements. This step ensures
that the app is being built according to the initial plan
and specifications without actually running the app.
6
Verification and Validation: Example
❖ Validation Example: In the validation phase, the team
starts testing the mobile banking app on actual devices.
They check if users can log in, transfer money, and view
their transaction history as intended. Testers perform
usability tests to ensure the app is user-friendly and
functional tests to ensure all features work correctly.
They might also involve real users to provide feedback on
the app's performance. This phase ensures that the app
works as expected and meets user needs in real-world
scenarios.
7
Software Testing
❖ Testing is intended to show that a program does what it
is intended to do and to discover program defects before it
is put into use.
❖ You check the results of the test run for errors, anomalies
or information about the program’s non-functional
attributes.
10
Approaches of Software Testing
13
Test Case (Template)
14
Test Case (Example)
15
Test Scenario and Test Case
Test Scenarios are one-liner statement
while
Test Cases is positive and negative inputs, navigation steps,
Expected results, pre and post condition, etc.
Test Scenarios are high-level actions.
while
Test Cases are low-level actions.
16
Test Scenario and Use Case
❖ Test Scenarios can be derived usually from Use cases
17
Levels of Software Testing
assess software with
Unit Testing respect to
Software Testing
implementation
Integration Subsystem
Testing Design
Architectural
System Testing
Design
Acceptance Requirement
Testing Analysis 19
Levels of Software Testing (based on Software
Activity)
Unit Testing Implementation
Integration Subsystem
Testing Design
Architectural
System Testing
Design
Acceptance Requirement
Testing Analysis 20
Levels of Software Testing (based on Software
Activity)
Unit Testing Implementation
Integration Subsystem
Testing Design
Architectural
System Testing
Design
Acceptance Requirement
Testing Analysis 21
Levels of Software Testing (based on Software
Activity)
Unit Testing Implementation
Integration Subsystem
Testing Design
Architectural
System Testing
Design
Acceptance Requirement
Testing Analysis 22
Levels of Software Testing (based on Software
Activity)
Unit Testing Implementation
Integration Subsystem
Testing Design
Architectural
System Testing
Design
Acceptance Requirement
Testing Analysis 23
Stages of testing
❖ Development testing,
○ where the system is tested during development to
discover bugs and defects.
❖ Release testing,
○ where a separate testing team test a complete version
of the system before it is released to users.
❖ User testing,
○ where users or potential users of a system test the
system in their own environment.
24
Development Testing
1. Unit testing,
■ where individual program units or object classes are tested.
■ Unit testing should focus on testing the functionality of objects
or methods.
2. Component testing,
■ where several individual units are integrated to create
composite components.
■ Component testing should focus on testing component
interfaces.
3. System testing,
■ where some or all of the components in a system are integrated
and the system is tested as a whole. 25
Unit Testing
❖ Unit testing is the process of testing individual
components in isolation.
❖ It is a defect testing process.
❖ Units may be:
○ Individual functions or methods within an object
○ Object classes with several attributes and methods
○ Composite components with defined interfaces used
to access their functionality.
26
assertEqual() – This
statement is used to
check if the result
obtained is equal to
the expected result.
https://www.geeksforgeeks.org/unit-testing-python-unittest/
Object Class Testing
❖ Complete test coverage of a class involves
○ Testing all operations associated with an object
○ Setting and interrogating all object attributes
○ Exercising the object in all possible states.
❖ Inheritance makes it more difficult to design object class
tests as the information to be tested is not localised.
28
assertTrue() / assertFalse()
– This statement is used to
verify if a given statement is
true or false.
The weather station testing
❖ Need to define test cases for reportWeather,
calibrate, test, startup and shutdown.
❖ Using a state model, identify sequences of
state transitions to be tested and the event
sequences to cause these transitions
❖ For example:
○ Shutdown -> Running-> Shutdown
○ Configuring-> Running-> Testing ->
Transmitting -> Running
○ Running-> Collecting-> Running->
Summarizing -> Transmitting -> Running
30
Weather station state diagram
Automated testing
❖ Whenever possible, unit testing should be automated so
that tests are run and checked without manual
intervention.
❖ In automated unit testing, you make use of a test
automation framework (such as JUnit) to write and run
your program tests.
❖ Unit testing frameworks provide generic test classes that
you extend to create specific test cases. They can then run
all of the tests that you have implemented and report,
often through some GUI, on the success of otherwise of
the tests.
33
Automated test components
❖ A setup part, where you initialize the system with the
test case, namely the inputs and expected outputs.
37
Equivalence Partition
38
Boundary Value Analysis
39