Se Mod4 PDF
Se Mod4 PDF
Se Mod4 PDF
Module-4Software 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. When you test software, you execute a program using artificial
data (test cases). You check the results of the test run for errors, anomalies or information about
the programs non-functional attributes.
Verification Validation
Are we building the product right, The Are we building the right product”.
software should conform to its The software should do what the user
specification. really requires
➢ Defect Testing
• To discover faults or defects in the software where its behaviour is incorrect or not in
conformance with its specification
• A successful test is a test that makes the system perform incorrectly and so exposes a defect
in the system.
3. System testing, where some or all of the components in a system are integrated and the
system is tested as a whole. System testing should focus on testing component interactions.
1.3.1 Unit testing
Unit testing is the process of testing individual components in isolation.
It is a defect testing process.
Units may include,
▪ Individual functions or methods within an object
▪ Object classes with several attributes and methods
▪ Composite components with defined interfaces used to access their functionality.
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.
Problem in unit testing : Inheritance makes it more difficult to design object class tests
as the information to be tested is not localised
➢ Example: The weather station object interface
Weather station is class here, in that identifier is method with attributes and associated test cases
are,
Reportweather->reportstatus->powersave->remotecontrol->reconfigure->restart-
>shutdown
➢ Testing Strategies
1. Partition testing: where you identify groups of inputs that have common characteristics
and should be processed in the same way.
▪ You should choose tests from within each of these groups.
2. Guideline-based testing: where you use testing guidelines to choose test cases.
▪ These guidelines reflect previous experience of the kinds of errors that
programmers often make when developing components.
➢ Partition testing
Input data and output results often fall into different classes where all members of a class
are related.
Each of these classes is an equivalence partition or domain where the program behaves in
an equivalent way for each class member.
Test cases should be chosen from each partition.
▪ The called and the calling component operate at different speeds and out-of-date
information is accessed.
➢ Interface testing guidelines
1. Design tests so that parameters to a called procedure are at the extreme ends of their
ranges.
2. Always test pointer parameters with null pointers.
3. Design tests which cause the component to fail.
4. Use stress testing in message passing systems.
5. In shared memory systems, vary the order in which components are activated.
1.3.3 System Testing
System testing during development involves integrating components to create a version of
the system and then testing the integrated system.
The focus in system testing is testing the interactions between components.
System testing checks that components are compatible, interact correctly and transfer the
right data at the right time across their interfaces. System testing tests the emergent
behavior of a system. The main goal of the system testing is to test the interaction between
the components.
During the system testing:
a. Checks the components are compatible
b. Checks that all components interaction correctly
c. Checking the Transfer of correct data at specified time across the interfaces of
units by keeping sequence diagram to know the sequence of activities.
Use-case testing
The use-cases developed to identify system interactions can be used as a basis for system
testing.
Each use case usually involves several system components so testing the use case forces
these interactions to occur.
The sequence diagrams associated with the use case documents the components and
interactions that are being tested
1 Set up a patient record with no known allergies, Check that a warning message
Prescribe medication for allergies that are known to is not issued by the system
exist
2 Set up a patient record with a known allergy Check that the warning is
issued by the system.
3 Set up a patient record in which allergies to two or Check that the correct warning
more drugs are recorded. Prescribe both of these for each drug is issued.
drugs separately
4 Prescribe two drugs that the patient is allergic too Check that two warnings are
correctly issued.
5 Prescribe a drug that issues a warning and overrule Check that the system requires
that warning the user to provide
information explaining why
the warning was overruled.
User or customer testing is a stage in the testing process in which users or customers
provide input and advice on system testing.
User testing is essential, even when comprehensive system and release testing have been
carried out.
▪ The reason for this is that influences from the user’s working environment have a
major effect on the reliability, performance, usability and robustness of a system.
These cannot be replicated in a testing environment.
Types of user testing
1.Alpha testing
▪ Users of the software work with the development team to test the software at the
developer’s site.
2.Beta testing
▪ A release of the software is made available to users to allow them to experiment
and to raise problems that they discover with the system developers.
3. Acceptance testing
▪ Customers test a system to decide whether or not it is ready to be accepted from the
system developers and deployed in the customer environment. Primarily for custom
systems.
5. Negotiate test results: if some minute errors occur then developers and customer should
discuss about that and will make some decision about the results.
6. Reject/accept system: if the system tested is up to mark , customer expection is met
without any error then it is subjected for acceptance. Else rejection
1. Code coverage
Every code segment that you write has at least one associated test so all code written
has at least one test.
2. Regression testing
A regression test suite is developed incrementally as a program is developed.
3. Simplified debugging
When a test fails, it should be obvious where the problem lies. The newly written code
needs to be checked and modified.
4. System documentation
The tests themselves are a form of documentation that describe what the code should be
doing
Testing is an expensive and laborious phase of the software process. As a result, testing
tools were among the first software tools to be developed. These tools now offer a range
of facilities and their use can significantly reduce the costs of testing.
A software testing workbench is an integrated set of tools to support the testing process. In
addition to testing frameworks that support automated test execution, a workbench may
include tools to simulate other parts of the system and to generate system test data.
Fig 9 shows some of the tools that might be included in such a testing workbench,
1. Test managerManages the running of program tests. The test manager keeps track of test
data, expected results and program facilities tested.
2. Test data generatorGenerates test data for the program to be tested. This may be
accomplished by selecting data from a database or by using patterns to generate random
data of the correct form.
3. OracleGenerates predictions of expected test results. Oracles may either be previous
program versions or prototype systems.
4. File comparatorCompares the results of program tests with previous test results and
reports differences between them.
5. Report generatorProvides report definition and generation facilities for test results.
6. Dynamic analyserAdds code to a program to count the number of times each statement
has been executed.
7 SimulatorDifferent kinds of simulators may be provided. Target simulators simulate the
machine on which the program is to execute
2. Software Evolution
• After systems have been deployed, they inevitably have to change if they are to remain
useful. Once software is put into use, new requirements emerge and existing requirements
change. Business changes often generate new requirements for existing software.
• The majority of changes are a consequence of new requirements that are generated in
response to changing business and user needs.
• Consequently, you can think of software engineering as a spiral process with requirements,
design, implementation and testing going on throughout the lifetime of the system. This is
illustrated in Figure 2.1.
• If the proposed changes are accepted, a new release of the system is planned. During release
planning, all proposed changes (fault repair, adaptation and new functionality) are
considered.
• The third law is, perhaps, the most interesting and the most contentious of Lehman’s laws.
It suggests that large systems have a dynamic of their own that is established at an early
stage in the development process. This determines the gross trends of the system
maintenance process and limits the number of possible system changes.
• Lehman’s fourth law suggests that most large programming projects work in what he
terms a saturated state. That is, a change to resources or staffing has imperceptible effects
on the long-term evolution of the system.
• Lehman’s fifth law is concerned with the change increments in each system release.
Adding new functionality to a system inevitably introduces new system faults. The more
functionality added in each release, the more faults there will be. Therefore, a large
increment in functionality in one system release means that this will have to be followed
by a further release where the new system faults are repaired.
• The sixth and seventh laws are similar and essentially say that users of software will
become increasingly unhappy with it unless it is maintained and new functionality is added
to it.
• The final law reflects the most recent work on feedback processes, although it is not yet
clear how this can be applied in practical software development.
The key factors that distinguish developmentand maintenance, and which lead to higher
maintenance costs, are:
1. Team stabilityAfter a system has been delivered, it is normal for the developmentteam to be
broken up and people work on new projects. The new teamor the individuals responsible for system
maintenance do not understand thesystem or the background to system design decisions.
2. Contractual responsibilityThe contract to maintain a system is usually separatefrom the system
development contract. The maintenance contract may begiven to a different company rather than
the original system developer. Thisfactor, along with the lack of team stability, means that there is
no incentivefor a development team to write the software so that it is easy to change.
3. Staff skillsMaintenance staff are often relatively inexperienced and unfamiliarwith the
application domain. Maintenance has a poor image among softwareengineers. It is seen as a less
skilled process than system development and isoften allocated to the most junior staff
4. Program age and structureAs programs age, their structure tends to be degradedby change, so
they become harder to understand and modify. Some systems havebeen developed without modern
software engineering techniques.
2. Average time required for impact analysisThis reflects the number of programcomponents that
are affected by the change request. If this time increases, it impliesthat more and more components
are affected and maintainability is decreasing.
The costs of re-engineering obviously depend on the extent of the work that iscarried out. There is
a spectrum of possible approaches to re-engineering, as shown in Figure 2.10
From a business perspective,you have to decide whether the business really needs the system.
From atechnical perspective, you have to assess the quality of the application software andthe
system’s support software and hardware.
From Figure 2.12, you can see that there are four clusters of systems:
1. Low quality, low business valueKeeping these systems in operation will beexpensive and the
rate of the return to the business will be fairly small. Thesesystems should be scrapped.
2. Low quality, high business valueThese systems are making an important businesscontribution
so they cannot be scrapped. However, their low quality meansthat it is expensive to maintain them.
These systems should be re-engineered toimprove their quality or replaced, if a suitable off-the-
shelf system is available.
3. High quality, low business valueThese are systems that don’t contribute muchto the business
but that may not be very expensive to maintain. It is not worthreplacing these systems so normal
system maintenance may be continued solong as no expensive changes are required and the system
hardware is operational.If expensive changes become necessary, they should be scrapped.
4. High quality, high business valueThese systems have to be kept in operation,but their high
quality means that you don’t have to invest in transformation orsystem replacement. Normal
system maintenance should be continued.
1. The use of the systemIf systems are only used occasionally or by a small numberof people, they
may have a low business value. A legacy system may havebeen developed to meet a business need
that has either changed or that can now
be met more effectively in other ways.
2. The business processes that are supportedWhen a system is introduced, businessprocesses to
exploit that system may be designed. However, changing theseprocesses may be impossible
because the legacy system can’t be adapted.Therefore, a system may have a low business value
because new processes can’tbe introduced.
3. The system dependabilitySystem dependability is not only a technical problembut also a
business problem. If a system is not dependable and the problemsdirectly affect the business
customers or mean that people in the business arediverted from other tasks to solve these problems,
the system has a low businessvalue.
4. The system outputsThe key issue here is the importance of the system outputsto the successful
functioning of the business
Factors that you should consider during the environment assessment are shownin Figure2.13.
To assess the technical quality of an application system, you have to assess a range of factors
(Figure 2.14 be collected are:
1. The number of system change requestsSystem changes tend to corrupt the system structure
and make further changes more difficult. The higher this value,the lower the quality of the
system
2. The number of user interfacesThis is an important factor in forms-based systemswhere each
form can be considered as a separate user interface. The moreinterfaces, the more likely that
there will be inconsistencies and redundanciesin these interfaces.
3. The volume of data used by the systemThe higher the volume of data (numberof files, size of
database, etc.), the more complex the system.