�MCA : III Sem �Professional Elective 4�Course code : 22MCA344�Course Title : Software Testing
Test Books : ��1. “Foundations of Software Testing- Fundamental Algorithm and Techniques “ � by Adithya P Mathur.��2. “Software testing and Analysis Process, Principals and Techniques”� by Paul C Jorgensen.
Module 1��Basic of Software Testing, Basic Principles, Test case selection and Adequacy
Software Testing : � * Software Testing is the process of evaluating and verifying that a software product or application does what it is supposed to do.� * Software Testing is a method to check whether the actual software product matches expected requirements and to ensure that software product is Defect free.
Errors are a part of our daily life. �
Humans make errors in their thoughts, actions, and in the products that might result from their actions.
Errors occur wherever humans are involved in taking actions and making decisions.��Error: When make mistakes while coding, we call these mistakes bugs.�
Error: Mistake done in the programmer while writing the code.�Failure : At the customer side, if they are facing some issue.�Defect : Difference between actual behavior and expected behavior.�Bug: Mis-matched output after test by the tester between actual and expected result.
Errors: Examples
Errors, Fault and Failures in the process of programming and testing
Test Automation
Developers and Testers as two Roles:
Developer is one who writes code & tester is one who tests code. Developer & Tester roles are different and complementary roles. Thus, the same individual could be a developer and a tester. It is hard to imagine an individual who assumes the role of a developer but never that of a tester, and viceversa.
Certainly, within a software development organization, the primary role of a individual might be to test and hence an individual assumes the role of a tester. Similarly, the primary role of an individual who designs applications and writes code is that of a developer.
SOFTWARE QUALITY
Software quality is a multidimensional quantity and is measurable.
Quality Attributes
These can be divided to static and dynamic quality attributes.
Static Quality Attributes : � It refers to the actual code and related documents.�Dynamic Quality Attributes : � Reliability � Correctness � Completeness � Consistency � Usability � Performance
Reliability: � It refers to the probability of failure free operation. Correctness: �Refers to the correct operation.�For a Tester, correctness is w.r.t to the requirements.�For a user, correctness is w.r.t the user manual .�Completeness: � Refers to the availability of all the features listed in the requirements or in the user manual. � An incomplete software is one that does not fully implement all features required.
Consistency: �Refers to adherence to a common set of conventions and assumptions. �Ex: All buttons in the user interface might follow a common-color coding convention.�Usability: �Refer to case with which an application can be used. This is an area in itself and there exist techniques for usability testing. � Psychology plays an important role in the design of techniques for usability testing. � Usability testing is a testing done by its potential users.
Performance: � Refers to the time the application takes to perform a requested task. Performance is considered as a non functional requirement.
Requirements, Behavior and Correctness�� Requirements leading to two different programs: ��Requirement 1: It is required to write a program that inputs two numbers and outputs the maximum of these.��Requirement 2: It is required to write a program that inputs a�sequence of integers and outputs the sorted version of this sequence.�
Requirements: Incompleteness� � Suppose that program max is developed to satisfy Requirement 1. The expected output of max when the input integers are 13 and 19 can be easily determined to be 19. �� Suppose now that the tester wants to know if the two integers are to be input to the program on one line followed by a carriage return, or on two separate lines with a carriage return typed in after each number. The requirement as stated above fails to provide an answer to this question. ��
Requirements: Ambiguity
Requirement 2 is ambiguous. It is not clear whether the input sequence is to sorted in ascending or in descending order. The behavior of sort program, written to satisfy this requirement, will depend on the decision taken by the programmer while writing sort.
Input domain (Input space)
Input domain (Continued)
Modified Requirement 2:
Valid/Invalid Inputs
request characters can be ``A'' and ``D'', but fails to answer the question ``What if the user types a different character ?’’
character other than ``A'' and ``D''. Any character other than ``A'’ and ``D'' is considered as invalid input to sort. The requirement for sort does not specify what action it should take when an invalid input is encountered.
Correctness and Testing
Testing and debugging�
Test and debug Cycle
���
A sample Test plan for Sort Program
1. Execute the program on at least two input sequences, one with “A” and the other with “D” as request characters.
2. Execute the program on an empty input sequence.
3. Test the program for robustness against error inputs such as “R'' typed in as the request character.
4. All failures of the test program should be recorded in a suitable file using the Company Failure Report Form.
Test case / data
A test case is a pair consisting of test data to be input to the program and the expected output. The test data is a set of values, one for each input variable.
A test set is a collection of zero or more test cases.
Sample test case for sort:
Test case 1:
Test data: <''A” 12 -29 32. >
Expected output: -29 12 32
Test case 2:� Test data: <“D” 12 -29 32. >� Expected output: 32 12 -29��Test case 3:� Test data: <“A”.>� Expected output: No input to be sorted in ascending order.��Test case 4: � Test data : <“D”.>� Excepted output: No input to be sorted in Descending order.�
Test case 5:� Test data: <'‘R” 3 17. >� Expected output: Invalid request character.
Valid characters: “A” and “D”.
�Test case 6:� Test data: <“A” c 17.>� Expected output: Invalid number.
Executing the Program
Execution of a program under test is the next significant step in the testing.
Program behavior�
Can be specified in several ways: plain natural language, a state diagram, formal mathematical specification, etc.
A state diagram specifies program states and how the program changes its state on an input sequence.
A program that input two integers X and Y, compares two values, sets the value of Z to the larger of 2.
Integer X,Y,Z
Input(X, Y)
If(X < Y)
Z=Y
else
Z=X
endif
Output (Z)
end
Program behavior: Example
Consider a menu driven application.
Program behavior: Example
Behavior: Observation and analysis
Oracle: Example
Relationship between the program under test and the oracle.
Oracle: Programs
Test Oracles can be manual or automated.��
Oracle: Construction
Test Matrix
Organizational Metrics
Organizational level metrics allow senior management to monitor the overall strength of the organization and points to area of weakness.
Project Metrics
Process Metrics � � Every project uses some test process. The big bang approach is one process some times used in relatively small single –person projects.�The goal of a process metrics is to access the goodness of the process.�
Testability�� According to IEEE, testability is the “degree to which a system or component facilitates the establishment of test criteria and the performance of tests to determine whether those criteria have been met”. �Two types:� 1. Static testability metrics � 2. Dynamic testability metrics.
Static testability metric: � Static metrics are those computed without having to execute the product code.�Dynamic metrics: � Dynamic metrics requires code execution. �Ex: when it is difficult to generate tests that satisfy the statement coverage criterion is considered to have low testability them one for which it is easier to construct such tests.
Software and Hardware testing
Software Testing | Hardware testing |
Does not integrate over time | Does integrate over time |
Fault present in the application will remain and no new faults will be found in unless the application is changed | VLSI chip, that might fail over time due to a fault that did not exist at the time chip was manufactured and tested |
Built-in self test meant for hardware product, rarely, can be applied to software designs and code | BIST intended to actually test for the correct functioning of a circuit |
It only detects faults that were present when the last change was made | Hardware testers generate test based on fault-models Ex: stuck_at fault model – one can use a set of input test patterns to test whether a logic gate is functioning as expected |
Two input NAND Gate
Testing and verification
DEFECT MANAGEMENT� Defect Management is an integral part of a development and test process in many software development organizations. It is a sub process of a the development process. �It includes the following: � Detect prevention � Discovery � Recording and reporting � Classification � Resolution � Production
Defect Prevention: It is achieved through a variety of process and tools.
They are
Good coding techniques.
Unit test plans.
Code Inspections.
Defect Discovery:
Defect discovery is the identification of defects in response to failures observed during dynamic testing or found during static testing. It involves debugging the code under test.
Defect Classification : Defects found are classified and recorded in a database. Classification becomes important in dealing with the defects. Classified into
High severity-to be attended first by developer
Low severity.
Resolution : Each defect, when recorded, is marked as ‘open’ indicating that it needs to be resolved. It required careful scrutiny of the defects, identifying a fix if needed, implementing the fix, testing the fix, and finally closing the defect indicating that every recorded defect is resolved prior to release.
Defect Prediction
Organizations often do source code Analysis to predict how many defects an application might contain before it enters the testing the phase.
Advanced statistical techniques are used to predict defects during the test process.
Tools are existing for Recording defects, and computing and reporting defect related statistics.
BugZilla - Open source
Fog-Buzz - commercially available tools.
EXECUTION HISTORY
Execution history of a program, also known as execution trace, is an organized collection of information about various elements of a program during a given execution. An execution slice is an executable subsequence of execution history. There are several ways to represent an execution history.
TEST GENERATION STRATEGIES
TEST GENERATION STRATEGIES
STATIC TESTING
Static testing is complementary to dynamic testing. This is carried out by an individual who did not write the code or by a team of individuals.
The test team responsible for static testing has access to requirements document, application, and all associated documents such as design document and user manual. Team also has access to one or more static testing tools. A static testing tool takes the application code as input and generates a variety of data useful in the test process.
WALKTHROUGHS
Walkthroughs and inspections are an integral part of static testing.
Walkthroughs is an informal process to review an application related document.
Walkthrough are an integral part of static testing.
Walkthrough are two types
2. Code walkthrough.
Inspection
Inspection plan:
Members of inspection team :
�Use of static code analysis tools in static testing �
Test Generation from Predicates
A techniques for generating tests that are guaranteed to detect certain faults in the coding of condition.
A condition is represented formally as a predicates.
Ex: “If the printer is ON and has paper then send the document for printing “
Predicate is denoted by pr, represents the condition part of the statement.
Pr: (printer_status=ON) ^ (printer_tray=¬empty)
A Simple predicate is a Boolean variable or a relational expression where one or more variable might be negated.�Ex: � q� q^r� a+b<c��A Compound predicate is a expression formed by joining two or more simple predicates.�Ex: (a+b<c)^(¬p)�
Fault model for predicate testing
Path predicate
The predicate which is associated with the path is knows as path predicates.
Path predicate expression is a set of Boolean expression which will give direction to specific path.
Path can be formed from number of goto statement, jump statements, switch statement etc.
Test Adequacy Criteria�� Adequacy criterion: A test adequacy criterion is a predicate that is true (satisfied) or false.� Usually a test adequacy criterion is expressed in the form of a rule for deriving a set of test rules from another program or specification.�
The goal here is to ensure internal components of the programs are working properly.
Coverages :
Path coverage
Covers all the paths.
Path coverage refers to designing test cases such that all lineally independent path are executed at least once.
Statement coverage
Statement coverage is a white box testing technique, which involves execution of all the statements at least once in a source code.
Branch coverage
Branch or decision coverage which aims to ensure that each one of the possible branch from each decision point is executed at least once.
Sensitivity
The sensitivity principle says that we should try to make faults easier to detect by making them cause failure more often.�� It can be applied in 3 ways :� 1. At design Level� 2. Analysis and testing level� 3. Environment level�
Redundancy
Restriction
Restriction principle is useful mainly during design and specification. It can be applied not only to solve a single problem but can also used in architectural level to simplify a whole set of analysis problems.
Partition
Visibility �.
Feedback
Sensitivity: better to fail every time than sometimes.�Redundancy : making intentions explicit .�Restriction: making the problem easier.�Partition: divide and conquer.�Visibility : measure progress Vs goal.�Feedback :applying lessons from experience in process and techniques.