Unit 6
Unit 6
The objective of the coding phase is to transform the design of a system into code
The programmers adhere to standard and well defined style of coding which they call their coding
standard. The main advantages of adhering to a standard style of coding are as follows:
• A coding standard gives uniform appearances to the code written by different engineers
• It facilitates code of understanding.
• Promotes good programming practices.
For implementing our design into a code, we require a good high level language
To make programming easier and more organized, every company or team follows certain rules for writing code.
Here are some key coding standards:
• Global variables are those that can be accessed from anywhere in the program.
• To avoid confusion, only certain types of data should be made global.
• Other data should be kept inside functions to prevent accidental changes.
Before writing code in any module (a part of a program), a header should be added with important details. This
helps others understand the code easily.
To keep code clean and easy to read, use a standard way of naming variables:
Global Variables – Start with a capital letter (e.g., TotalCount).
Local Variables – Use small letters (e.g., sum).
Constants – Use all capital letters (e.g., MAX_VALUE).
The following are some representative coding guidelines recommended by many software development
organizations.
Simple Coding Guidelines for Better Code
To write clean, understandable, and maintainable code, follow these simple rules:
• A function should not modify global variables or perform file operations unless it’s clearly mentioned in its
name or comments.
• Hidden side effects make debugging and understanding the code difficult.
Code Review :
Code review for a model is carried out after the module is successfully compiled and the 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.
These two types code review techniques are
1. code inspection
2. code walk through
UNIT 6. CODE DESIGN & SOFTWARE TESTING
CODE INSPECTION
The aim of code inspection is to discover some common types of errors caused due to
oversight and improper programming.
In addition to the commonly made errors, observance to coding standards is also checked
during code inspection.
Good software development companies collect statistics regarding different types of errors
commonly committed by their engineers and identify the type of errors most frequently
committed.
Following is a list of some classical programming errors which can be checked during code
inspection:
• Use of uninitialized variables.
• Jumps into loops.
• Nonterminating loops.
• Incompatible assignments.
• Array indices out of bounds.
• Improper storage allocation and deallocation.
• Mismatches between actual and formal parameter in procedure calls.
• Use of incorrect logical operators or incorrect precedence among operators.
• Improper modification of loop variables.
• Comparison of equally of floating point variables, etc.
• Each member selects some test cases and simulates execution of the code by hand
(i.e. trace execution through each statement and function execution).
• The main objectives of the walk through are to discover the algorithmic and logical
errors in the code.
• The members note down their findings to discuss these in a walk through
meeting Some of these guidelines are the following:
UNIT 6. CODE DESIGN & SOFTWARE TESTING
• The team performing code walk through should not be either too big or too small.
Ideally, it should consist of between three to seven members.
• Discussion should focus on discovery of errors and not on how to fix the discovered
errors.
• Top level should not participate in discussion.
6. 2 Testing Fundamentals
Testing checks whether the actual software matches the expected requirements and
ensures the software is bug-free.
Testing is the process of executing a program to find errors. To make our software perform
well it should be error-free. If testing is done successfully it will remove all the errors from the
software.
1. The first and the foremost objective of software testing is to ensure that it fulfills all
the requirements of the customer
2. Second main objective is to find out the defects or issues occurring in the application
before it are encountered by the end user.
3. Thirdly, to evaluate the overall performance of the application.
4. Providing a high quality product to the end user.
5. To evaluate security related issues for the application under test
Software testing is a process that to find out defects from the software and helps to make
quality software.
A good process for software testing will help the developer or the tester to find the
defects or issues in the software faster.
If you want to fix the defects fast, you should know the process. Here 7 steps in
software testing process are discussed.
Seven Steps of Testing Process / Phases of Software Testing life cycle (STLC)
UNIT 6. CODE DESIGN & SOFTWARE TESTING
1. Requirement Analysis:
• In this phase quality assurance team understands and analyze requirements to
determine what needs to be tested.
• If anything is missing or not understandable then the quality assurance team meets
with the stakeholders to better understand the detailed knowledge of requirements.
2. Test Planning:
• Based on the requirements, a test plan is created which outlines the scope,
objectives, resources, schedule, and approach for testing.
• This plan serves as a roadmap for the entire testing process.
• In this phase manager of the testing, team calculates the estimated effort and cost for
the testing work.
• This phase gets started once the requirement-gathering phase is completed.
5.Test Execution
• In this phase, the actual testing is performed according to the test plan and test cases. Testers
execute the test cases, record the results, and report any defects found.
UNIT 6. CODE DESIGN & SOFTWARE TESTING
6 Test Closure
• Once all test activities are completed, a test closure report is prepared summarizing the
testing activities, achievements, issues encountered, and lessons learned during the
testing process.
The software testing life cycle (STLC) is a systematic and well-structured process of testing
software applications to uncover defects and errors and check whether it meets the specified
requirements.
It is an integral process in software development involving different phases, where each phase
has its own goals and deliverables.
Types of Testing:-
1. Unit Testing
It focuses on the smallest unit of software design. In this, we test an individual unit or group
of interrelated units. It is often done by the programmer by using sample input and observing
its corresponding outputs.
2. Integration Testing
The objective is to take unit-tested components and build a program structure that has been
dictated by design. Integration testing is testing in which a group of components is combined
to produce output.
Integration testing is of four types: (i) Top-down (ii) Bottom-up (iii) Sandwich (iv) Big-Bang
3. Regression Testing
Every time a new module is added leads to changes in the program. This type of testing
makes sure that the whole component works properly even after adding components to the
complete program.
UNIT 6. CODE DESIGN & SOFTWARE TESTING
4. Smoke Testing
This test is done to make sure that the software under testing is ready or stable for further
testing
It is called a smoke test as the testing of an initial pass is done to check if it did not catch the
fire or smoke in the initial switch on.
Example:
If the project has 2 modules so before going to the module
make sure that module 1 works properly
5. Alpha Testing
This is a type of validation testing. It is a type of acceptance testing which is done before the
product is released to customers. It is typically done by QA people.
Example:
When software testing is performed internally within the organization
6. Beta Testing
The beta test is conducted at one or more customer sites by the end-user of the software.
This version is released for a limited number of users for testing in a real-time environment
Example:
When software testing is performed for the limited number of people
7. System Testing
This software is tested such that it works fine for the different operating systems. It is covered
under the black box testing technique. In this, we just focus on the required input and output
without focusing on internal working.
In this, we have security testing, recovery testing, stress testing, and performance testing
Example: This includes functional as well as nonfunctional testing
8. Stress Testing
In this, we give unfavourable conditions to the system and check how they perform in those
conditions.
10. Object-Oriented Testing
This testing is a combination of various testing techniques that help to verify and validate
object-oriented software. This testing is done in the following manner:
• Testing of Requirements,
• Design and Analysis of Testing,
• Testing of Code,
• Integration testing,
• System testing,
• User Testing.
11. Acceptance Testing
Acceptance testing is done by the customers to check whether the delivered products perform
the desired tasks or not, as stated in requirements.
UNIT 6. CODE DESIGN & SOFTWARE TESTING
Types of Testing
• Black box testing is a software testing technique where the internal workings of the
system under test are not known to the tester.
UNIT 6. CODE DESIGN & SOFTWARE TESTING
• Instead, the tester focuses solely on the inputs and outputs of the software
without considering its internal code structure, algorithms, or implementation
details. The term "black box" refers to the idea that the system is treated as a
closed box, with only its observable behaviors being considered during testing.
• This can be applied to every level of software testing such as Unit, Integration,
System, and Acceptance Testing.
• Equivalence Partitioning: Dividing the input domain into classes or partitions and
selecting representative values from each partition to design test cases.
• Boundary Value Analysis: Testing the boundaries between equivalence classes, as
errors often occur at the boundaries of input ranges.
• Decision Table Testing: Creating decision tables to test all possible combinations of
inputs and their corresponding actions or outcomes.
Overall, black box testing helps ensure the quality and reliability of software by focusing on
its external behavior and user experience.
Advantages:
Disadvantages:
1. Limited Coverage: Black box testing may not cover all possible scenarios, leading to
potential gaps in test coverage.
2. Inefficiency in Complex Systems: Testing without knowledge of internal
workings can be inefficient, especially in complex systems where understanding
internal behavior could streamline testing.
3. Difficulty in Defect Localization: Identifying the root cause of defects may be
challenging since testers lack visibility into the internal code.
UNIT 6. CODE DESIGN & SOFTWARE TESTING
4. Overlap with Other Testing Methods: There can be overlap with other testing
methods, leading to redundancy in testing efforts.
5. Dependency on Requirements: Effectiveness depends heavily on the
quality and completeness of requirements documentation. If requirements
are incomplete or inaccurate, it may lead to ineffective testing.
Example 2 :
Assume, we have to test a field which accepts Age 18 – 56
valid Input: 18 – 56
UNIT 6. CODE DESIGN & SOFTWARE TESTING
For each boundary, we test +/-1 in the least significant digit of either side of the boundary.
Creating decision tables to test all possible combinations of inputs and their corresponding
actions or outcomes.A decision table puts causes and their effects in a matrix. There is a
unique combination in each column.
It focuses on the business rule where logical conditions or decision-making steps are
required. Inputs are identified by the testers on which the actions are to be performed
based on conditions.
UNIT 6. CODE DESIGN & SOFTWARE TESTING
Here, the development team will review the entire coding part line by line to ensure the
correctness of the code. If he/she finds any dissimilarities or errors in the code, they will correct
or fix the errors in the coding or designs.
Here, the process is entirely carried out manually and it is efficient since the checking code or
design is manually checked by humans.
White box testing techniques include:
• Statement Coverage: Ensuring that each statement in the code is executed at least
once during testing.
• Branch Coverage: Ensuring that each decision point (branch) in the code is exercised
by at least one test case, including both true and false branches.
UNIT 6. CODE DESIGN & SOFTWARE TESTING
• 4 test cases required such that all branches of all decisions are covered, i.e, all edges
of flowchart are covered
• Path Coverage: Ensuring that every possible path through the code is traversed by at
least one test case, aiming to test all possible combinations of branches and conditions.
• Mutation Testing: Introducing small changes (mutations) to the code and running test
cases to detect if the tests can identify these changes. This helps assess the
effectiveness of the test suite.
White box testing is particularly useful for:
• Identifying code defects, such as logical errors, syntax errors, or incorrect assumptions.
• Assessing code quality, including readability, maintainability, and adherence to coding
standards.
• Achieving thorough test coverage and ensuring that all code paths are tested.
Automation Potential: Many white box testing techniques, such as code reviews, static
analysis, and unit testing, can be automated, allowing for efficient and continuous testing.
The advantages of white-box testing include:
1. Spotting errors and problems more quickly
2. Providing introspection, or the ability to look into the software and examine it more
thoroughly
3. Finding hidden bugs more efficiently and ensuring greater stability
4. Optimizing the code due to the programming knowledge required
5. Obtaining maximum coverage of the different path present
UNIT 6. CODE DESIGN & SOFTWARE TESTING
Source Code The tester cannot access the source The tester is aware of the source
Access code of the software. code and internal workings of the
software.
Interface of You can conduct Black box testing at You can conduct White box testing
Operation the software interface. It requires no by ensuring that all the internal
concern with the software’s internal operations take place according
logical structure. to the specifications.
Purpose of It tests the functions of the software. It tests the structure of the
Testing software.
Basis of You can initiate this test on the basis You can only start this type of
Initiation of the requirement specifications testing software after a detailed
document. design document.
Programming Testers don’t require a knowledge of Testers mandatorily require a
Knowledge programming. knowledge of programming.
Assessment This testing assesses software This testing assesses software
behavior. logic.
Level of Testing Higher levels of software testing Lower levels of software testing
generally involve Black Box testing. usually involve White Box testing.
Other Names You can also call it closed testing. You can also call it clear box
testing.
Time It consumes less time. It consumes more time.
Consumed
Algorithm It does not work well for algorithm It is completely suitable and
Testing testing. preferable for algorithm testing.
Methods of One can perform it using various trial You can better test data domains
Testing and error methods and ways. and internal or inner boundaries.
Types of Black Box Testing types: White Box Testing types:
Testing
• Regression Testing • Condition Testing
• Functional Testing • Path Testing
• Non-Functional Testing • Loop Testing
Examples Example: A user searching Example: When a user inputs to
something on a search engine like check and verify the loops.
Google using certain keywords.
UNIT 6. CODE DESIGN & SOFTWARE TESTING
Unit testing, is a testing technique using which individual modules are tested to determine if
there are any issues by the developer himself. It is concerned with functional correctness of
the standalone modules.
• The main aim is to isolate each unit of the system to identify, analyze and fix the defects.
• A unit is the smallest testable part of any software. It usually has one or a few inputs and
usually a single output.
• In procedural programming, a unit may be an individual program,
function, Procedure, etc.
• In object-oriented programming, the smallest unit is a method, which may belong to a
base/ super class, abstract class or derived/ child class. Unit testing frameworks, drivers,
stubs, and mock/ fake objects are used to assist in unit testing.
2. Types:
3. Test Scenarios : Integration test scenarios are based on the interactions and data flow
between modules, including validating input/output interfaces, data exchange, and error
handling.
4. Test Techniques:
• Black Box Testing: Focuses on testing functionality without knowledge of
internal structures.
• White Box Testing: Examines internal logic and code paths to ensure correct
interactions.
• Interface Testing: Verifies communication and data exchange between modules.
• Error Handling Testing: Ensures modules handle errors and exceptions
correctly.
Advantages:
Test data refers to the input data and conditions that are used during software testing to verify
the correctness, completeness, and quality of a software application or system.
It includes various types of data such as:
1. Input Data: Data provided to the software under test to simulate real-world usage
scenarios. This can include user inputs, API calls, database entries, file inputs, and system
configurations.
2. Expected Outputs: The expected results or behaviors of the software under test for a
given set of input data. These expected outcomes are used to validate the correctness of
the software's responses.
3. Boundary Conditions: Data representing the boundaries or limits of valid input ranges.
Testing with boundary conditions helps identify potential issues at the edges of acceptable
values.
4. Error Conditions: Data designed to trigger error-handling mechanisms within the
software. Testing with error conditions helps ensure that the software behaves
appropriately when encountering unexpected or invalid input.
5. Edge Cases: Uncommon or extreme scenarios that are unlikely to occur during normal
usage but may reveal vulnerabilities or weaknesses in the software. Testing with edge
cases helps improve the robustness and reliability of the software.
Test data is essential for conducting effective software testing, as it enables testers to evaluate
the behavior and performance of the software under various conditions.
By carefully selecting and preparing test data, testers can uncover defects, validate
functionality, and ensure that the software meets the desired quality standards before
deployment.
Example:
UNIT 6. CODE DESIGN & SOFTWARE TESTING
Here’s the example of test data for the calculator application presented in a
table format:
Test Scenario Operand 1 Operand 2 Expected Output
Addition Operation 5 3 8
Subtraction Operation 10 7 3
Multiplication Operation -4 6 -24
Division Operation 12 4 3
Division by Zero Error 8 0 Error: Division by zero
This table organizes the test scenarios, input data, and expected outputs in a
clear and concise format, making it easy to understand and reference during
testing.
Example :
Let's walk through an example of test data preparation in software engineering using a simple
UNIT 6. CODE DESIGN & SOFTWARE TESTING
In this table:
• Test Scenario: Describes the specific scenario being tested.
• Input Data: Specifies the data provided for the test scenario.
• Expected Outcome: Defines the expected result or behavior when the provided
input data is used.
This table organizes the test scenarios, input data, and expected outcomes in a structured
manner, making it easier to plan and execute testing activities for the login functionality of
the web application.
Verification is the process of checking that a software achieves its goal without any bugs. It
is the process to ensure whether the product that is developed is right or not. It verifies
whether the developed product fulfills the requirements that we have. Verification is static
testing.
Validation is the process of checking whether the software product is up to the mark or in
other words product has high level requirements. It is the process of checking the validation of
product i.e. it checks what we are developing is the right product. it is validation of actual and
expected product. Validation is the dynamic testing.
Verification Validation
It includes checking documents, design, It includes testing and validating the actual product.
codes and programs.
Verification is the static testing. Validation is the dynamic testing.
It does not include the execution of the
It includes the execution of the code.
code.
Methods used in verification are Methods used in validation are Black Box Testing,
reviews, walkthroughs, inspections and White Box Testing and non- functional testing.
desk- checking.
It checks whether the software meets the
It checks whether the software
requirements and expectations of a customer or not.
conforms to specifications or not.
It can find the bugs in the early stage of It can only find the bugs that could not be found by the
the development. verification process.
The goal of verification is application
The goal of validation is an actual product.
and software architecture and
specification.