Unit6 Software Coading and Testing
Unit6 Software Coading and Testing
Prepared By
Prof. Mital Sarvaiya
Computer Engineering
BHGCET - Rajkot
Topics:
A coding standard lists several rules to be followed such as, the way
variables are to be named, the way the code is to be laid out, error return
conventions, etc. The following are some representative coding standards
• Rules for limiting the use of global
• These rules list what types of data can be declared global and what cannot.
Naming conventions for global & local variables & constant identifiers
• A possible naming convention can be that global variable names always
start with a capital letter, local variable names are made of small
letters, and constant names are always capital letters.
Contents of the headers preceding codes for different modules
• The information contained in the headers of different modules should be
standard for an organization.
• The exact format in which the header information is organized in the
header can also be specified
Coding Standard and coding Guidelines Continue…
Coding guidelines
Do not use a coding style that is too clever or too difficult to understand
Do not use an identifier for multiple purposes
The code should be well-documented
The length of any function should not exceed 10 source lines
Do not use goto statements
Coding Standard and coding Guidelines Continue…
• Code Review is carried out after the module is successfully compiled and
all the syntax errors have been eliminated.
• Code Reviews are extremely cost-effective strategies for reduction in
coding errors and to produce high quality code.
Types of Review
1) Code Walk Through
2) Code Inspection
Code Review Continue…
1)Unit Testing
• Unit is the smallest part of a software system which is testable.
• It may include code files, classes and methods which can be tested
individually for correctness.
• Unit Testing validates small building block of a complex system before
testing an integrated large module or whole system
• The unit test focuses on the internal processing logic and data
structures within the boundaries of a component.
• The module is tested to ensure that information properly flows into and
out of the program unit
• Local data structures are examined to ensure that data stored
temporarily maintains its integrity during execution
Testing Strategies Continue…
In such case the missing software is replaced by Stubs and Drivers and
simulate the interface between the software components in a simple manner
Testing Strategies Continue…
2) Integration Testing
Integration testing is the process of testing the interface between two
software units or modules
It can be done in 3 ways
Big Bang Approach Top Down Approach Bottom Up Approach
● Regression Testing
• Repeated testing of an already tested program, after modification, to
discover any defects introduced or uncovered as a result of the changes in
the software being tested
• Regression testing is done by re-executing the tests against the modified
application to evaluate whether the modified code breaks anything
which was working earlier
• Anytime we modify an application, we should do regression testing
• It gives confidence to the developers that there is no unexpected side
effects after modification
Testing Strategies Continue…
● Smoke Testing
• Smoke Testing is an integrated testing approach that is commonly used
when product software is developed
• This test is performed after each Build Release
• Smoke testing verifies – Build Stability
• This testing is performed by “Tester” or “Developer”
• This testing is executed for Integration Testing, System Testing &
Acceptance Testing
• What to Test?
– All major and critical functionalities of the application is tested
– It does not go into depth to test each functionalities
– This does not incudes detailed testing for the build
Testing Strategies Continue…
• It test the build just to check if any major or critical functionalities are
broken
• If there are smoke or Failure in the build after Test, build is rejected and
developer team is reported with the issue
Testing Strategies Continue…
3) Validation Testing
• The process of evaluating software to determine whether it satisfies
specified business requirements (client’s need).
• It provides final assurance that software meets all informational,
functional, behavioral, and performance requirements
• When custom software is build for one customer, a series of acceptance
tests are conducted to validate all requirements
• It is conducted by end user rather then software engineers
• If software is developed as a product to be used by many customers, it is
impractical to perform formal acceptance tests with each one
• Most software product builders use a process called alpha and beta testing
to uncover errors that only the end user seems able to find
Testing Strategies Continue…
● Alpha Test
• The alpha test is conducted at the developer’s site by a representative
group of end users
• The software is used in a natural setting with the developer “looking over
the shoulders” of the users and recording errors and usage problems
• The alpha tests are conducted in a controlled environment
● Beta Test
• The beta test is conducted at one or more end-user sites
• Developers are not generally present
• Beta test is a “live” application of the software in an environment that
can not be controlled by the developer
• The customer records all problems and reports to the developers at
regular intervals
• After modifications, software is released for entire customer base
Testing Strategies Continue…
4) System Testing
• In system testing the software and other system elements are tested.
• To test computer software, you spiral out in a clockwise direction along
streamlines that increase the scope of testing with each turn.
• System testing verifies that all elements mesh properly and overall
system function/performance is achieved.
• System testing is actually a series of different tests whose primary
purpose is to fully exercise the computer-based system.
Testing Techniques and Test Case
Software Testing Techniques help you design better test cases. Since
exhaustive testing is not possible; Manual Testing Techniques help reduce the
number of test cases to be executed while increasing test coverage. They help
identify test conditions that are otherwise difficult to recognize.
Example
Input condition is valid between 1 to 10 Boundary values 0,1,2 and 9,10,11
Testing Techniques and Test Case Continue…
Equivalent Class Partitioning allows you to divide set of test condition into a
partition which should be considered the same. This software testing method
divides the input domain of a program into classes of data from which test
cases should be designed.
The concept behind this technique is that test case of a representative value of
each class is equal to a test of any other value of the same class. It allows you
to Identify valid as well as invalid equivalence classes.
Example:
Input conditions are valid between
• 1 to 10 and 20 to 30
Testing Techniques and Test Case Continue…
4) State Transition:
In State Transition technique changes in input conditions change the state of
the Application Under Test (AUT). This testing technique allows the tester to
test the behavior of an AUT. The tester can perform this action by entering
various input conditions in a sequence. In State transition technique, the
testing team provides positive as well as negative input test values for
evaluating the system behavior.
Error Guessing:
is a software testing technique based on guessing the error which can prevail
in the code. The technique is heavily based on the experience where the test
analysts use their experience to guess the problematic part of the testing
application. Hence, the test analysts must be skilled and experienced for better
error guessing.
Test Suites Design
• Test suite is a container that has a set of tests which helps testers in
executing and reporting the test execution status. It can take any of the
three states namely Active, In progress and completed.
• A Test case can be added to multiple test suites and test plans. After
creating a test plan, test suites are created which in turn can have any
number of tests.
• Test suites are created based on the cycle or based on the scope. It can
contain any type of tests, viz - functional or Non-Functional.
Test Suites Design Continue…
!)Black-box
Also known as specification-based testing
• Tester has access only to running code and the specification it is
supposed to satisfy
• Test cases are written with no knowledge of internal workings of the
code
• No access to source code
• So test cases don’t worry about structure
• Emphasis is only on ensuring that the contract is met
Advantage
• Scalable; not dependent on size of code
• Testing needs no knowledge of implementation
• Tester and developer can be truly independent of each other
• Tests are done with requirements in mind
• Does not excuse inconsistencies in the specifications
• Test cases can be developed in parallel with code
Testing Conventional Applications Continue…
Two techniques are used
Equivalence Partitioning
• Input data for a program unit usually falls into a number of partitions,
e.g. all negative integers, zero, all positive numbers
• Each partition of input data makes the program behave in a similar
way
• Two test cases based on members from the same partition is likely to
reveal the same bugs
Boundary Value Analysis (BVA)
• It arises from the fact that most program fail at input boundaries
• Boundary testing is the process of testing between extreme ends or
boundaries between partitions of the input values.
• In Boundary Testing, Equivalence Class Partitioning plays a good role
• Boundary Testing comes after the Equivalence Class Partitioning
• The basic idea in boundary value testing is to select input variable values
at their:
Testing Conventional Applications Continue…
!!)White-Box
Also known as structural testing
• White Box Testing is a software testing method in which the internal
structure/design/implementation of the module being tested is known to
the tester
• Focus is on ensuring that even abnormal invocations are handled
gracefully
• Using white-box testing methods, you can derive test cases that
– Guarantee that all independent paths within a module have been
exercised at least once
– Exercise all logical decisions on their true and false sides
– Execute all loops at their boundaries
– Exercise internal data structures to ensure their validity
Testing Conventional Applications Continue…