Unit Testing
Unit Testing
• Testing of each unit or an individual component
of the software application.
• First level of functional testing.
• The aim
– validate unit components with its performance.
• Unit
– single testable part of a software system
– tested during the development phase of the application software.
• Purpose
– test the correctness of isolated code.
• White box testing approach
• Whenever the application is ready
– Test engineer, he/she will start checking every component of the module or
module of the application independently or one by one, and this process is
known as Unit testing or components testing.
Types of Unit Testing
• Manual unit testing
• Automated unit testing
Unit Testing Features
• Test each component of the program individually.
• Before integration tests.
• Check that the code they've written adheres to specifications and performs as expected.
• Walking through the code, reviewing it, and inspecting
• Automated testing is a good standard.
• Manual testing is also viable
• Find and eliminate software flaws quickly before they may create any significant problems.
• Saves the amount of time and money
Unit Testing Techniques
1. Functional Testing Technique
2. Structural Technique
3. Error-Based Techniques
1. Functional Testing Technique
• Tests the software's features
– to validate features and
– ensure that the program operates as designed.
• Black box test,
– Input domain testing
• Boundary Value
• Equivalence Partitioning
– Syntax Checking
Equivalence Partitioning
• Input data units are divided into equivalent
partitions
– derive test cases
• reduces time required for testing because of small number of test
cases.
• range in the input field.
Boundary Testing
• Test boundary values
– input values near the boundary have higher chances of
error.
• Valid & Invalid Boundary value .
Example on Boundary Value Analysis
Syntax Testing
• Testing the System inputs
• usually automated
– produces a large number of tests.
• Internal and external inputs have to conform the below formats:
– Format of the input data from users.
– File formats.
– Database schemas.
Syntax Testing – Steps
• Identify the target language or format.
• Define the syntax of the language.
• Validate and Debug the syntax.
2. Structural Technique
• White box testing,
–developing test cases with an understanding of a
system's fundamental architecture and code.
–development team , testers to have an in-depth
understanding of the code for test execution
Mutation testing
• Certain statements of the source code are changed/mutated to check if the test cases
are able to find errors in source code.
• Goal
– ensuring the quality of test cases in terms of robustness that it should fail the mutated
source code.
• The changes made in the mutant program should be kept extremely small that it does
not affect the overall objective of the program.
• Fault-based testing strategy
Data Flow Testing
• Analyze the flow of data in the program.
• Process of collecting information about how the variables flow the data in
the program.
• Uses control flow graph to detect illogical things that can interrupt the flow
of data.
• Anomalies in the flow of data are detected at the time of associations
between values and variables due to:
– If the variables are used without initialization.
– If the initialized variables are not used at least once.
Data Flow Testing
Predicate use (p-use)
•If the value of a variable is used to decide an execution path is considered as predicate use
(p-use).
Computation use (c-use)
•If the value of a variable is used to compute a value for output or for defining another
variable.
A path from a variable definition to a use is called a def-use path
Def-use occurrences
• Basic model of Structural testing.
• Check the implementation order of commands or statements of the
code over a control structure.
• A specific part of an extensive program is selected by the test engineer
to set the testing path.
• The entire test is based on how the control is executed during the
code.
• The complete information of all the software's features and logic is
necessary to execute the control flow testing.
Control Flow Testing
Control Flow Graphs
Slice-based testing
• Takes a slice or a group of program statements in the program for testing particular
test conditions or cases that may affect a value at a particular point of interest.
• Used for the purpose of debugging in order to find the bugs more easily and quickly.
2. Dynamic slicing:
4.3_Unit Testing.ppt  gfdfghhhhhhhhhhhhh
4.3_Unit Testing.ppt  gfdfghhhhhhhhhhhhh
4.3_Unit Testing.ppt  gfdfghhhhhhhhhhhhh
4.3_Unit Testing.ppt  gfdfghhhhhhhhhhhhh
4.3_Unit Testing.ppt  gfdfghhhhhhhhhhhhh
4.3_Unit Testing.ppt  gfdfghhhhhhhhhhhhh
4.3_Unit Testing.ppt  gfdfghhhhhhhhhhhhh
4.3_Unit Testing.ppt  gfdfghhhhhhhhhhhhh
4.3_Unit Testing.ppt  gfdfghhhhhhhhhhhhh
4.3_Unit Testing.ppt  gfdfghhhhhhhhhhhhh
4.3_Unit Testing.ppt  gfdfghhhhhhhhhhhhh
4.3_Unit Testing.ppt  gfdfghhhhhhhhhhhhh
4.3_Unit Testing.ppt  gfdfghhhhhhhhhhhhh
4.3_Unit Testing.ppt  gfdfghhhhhhhhhhhhh
4.3_Unit Testing.ppt  gfdfghhhhhhhhhhhhh
4.3_Unit Testing.ppt  gfdfghhhhhhhhhhhhh

4.3_Unit Testing.ppt gfdfghhhhhhhhhhhhh

  • 1.
  • 3.
    Unit Testing • Testingof each unit or an individual component of the software application. • First level of functional testing. • The aim – validate unit components with its performance.
  • 4.
    • Unit – singletestable part of a software system – tested during the development phase of the application software. • Purpose – test the correctness of isolated code. • White box testing approach • Whenever the application is ready – Test engineer, he/she will start checking every component of the module or module of the application independently or one by one, and this process is known as Unit testing or components testing.
  • 9.
    Types of UnitTesting • Manual unit testing • Automated unit testing
  • 10.
    Unit Testing Features •Test each component of the program individually. • Before integration tests. • Check that the code they've written adheres to specifications and performs as expected. • Walking through the code, reviewing it, and inspecting • Automated testing is a good standard. • Manual testing is also viable • Find and eliminate software flaws quickly before they may create any significant problems. • Saves the amount of time and money
  • 11.
    Unit Testing Techniques 1.Functional Testing Technique 2. Structural Technique 3. Error-Based Techniques
  • 12.
    1. Functional TestingTechnique • Tests the software's features – to validate features and – ensure that the program operates as designed. • Black box test, – Input domain testing • Boundary Value • Equivalence Partitioning – Syntax Checking
  • 13.
    Equivalence Partitioning • Inputdata units are divided into equivalent partitions – derive test cases • reduces time required for testing because of small number of test cases. • range in the input field.
  • 23.
    Boundary Testing • Testboundary values – input values near the boundary have higher chances of error. • Valid & Invalid Boundary value .
  • 24.
    Example on BoundaryValue Analysis
  • 33.
    Syntax Testing • Testingthe System inputs • usually automated – produces a large number of tests. • Internal and external inputs have to conform the below formats: – Format of the input data from users. – File formats. – Database schemas.
  • 34.
    Syntax Testing –Steps • Identify the target language or format. • Define the syntax of the language. • Validate and Debug the syntax.
  • 35.
    2. Structural Technique •White box testing, –developing test cases with an understanding of a system's fundamental architecture and code. –development team , testers to have an in-depth understanding of the code for test execution
  • 37.
    Mutation testing • Certainstatements of the source code are changed/mutated to check if the test cases are able to find errors in source code. • Goal – ensuring the quality of test cases in terms of robustness that it should fail the mutated source code. • The changes made in the mutant program should be kept extremely small that it does not affect the overall objective of the program. • Fault-based testing strategy
  • 39.
    Data Flow Testing •Analyze the flow of data in the program. • Process of collecting information about how the variables flow the data in the program. • Uses control flow graph to detect illogical things that can interrupt the flow of data. • Anomalies in the flow of data are detected at the time of associations between values and variables due to: – If the variables are used without initialization. – If the initialized variables are not used at least once.
  • 40.
  • 41.
    Predicate use (p-use) •Ifthe value of a variable is used to decide an execution path is considered as predicate use (p-use). Computation use (c-use) •If the value of a variable is used to compute a value for output or for defining another variable. A path from a variable definition to a use is called a def-use path
  • 43.
  • 44.
    • Basic modelof Structural testing. • Check the implementation order of commands or statements of the code over a control structure. • A specific part of an extensive program is selected by the test engineer to set the testing path. • The entire test is based on how the control is executed during the code. • The complete information of all the software's features and logic is necessary to execute the control flow testing. Control Flow Testing
  • 45.
  • 49.
    Slice-based testing • Takesa slice or a group of program statements in the program for testing particular test conditions or cases that may affect a value at a particular point of interest. • Used for the purpose of debugging in order to find the bugs more easily and quickly.
  • 52.