Coding and Testing in Software Engineering

Coding:

The goal of the coding or programming phase is to translate the design of the system produced during the design phase into code in a given programming language. It is then executed on a computer to verify whether the design is correct or not. The coding phase affects both testing and maintenance phase. As we know, the time spent in coding is a small percentage of software cost, while testing and maintenance consume the major percentage. So it is clear that the goal of coding is not to reduce the implementation cost, but to reduce the cost of testing and maintenance phase. There are many different criteria for judging a program which includes readability, size of the program, execution time, and required memory. Having readability and understandability as a clear objective of the coding activity can itself help in producing software that is more maintainable.

 

Coding Style (Programming Style):

 

Coding style, also known as programming style, is a set of coding rules or guidelines used when writing the source code for a computer program.Coding style refers to the technique used in writing the source code for a computer program.

Following a particular coding style will help programmers quickly read and understands the program as well as avoid making errors.  Programmers spend an enormous amount of time reading and studying code when they are writing, testing, and debugging their programs. Using good programming style allows this process to proceed much more easily. 

Good software development organizations normally require their programmers to maintain some well-defined and standard style of coding called coding standards. They usually formulate their own standards and guidelines on what suits their organization best and based on the types of software they develop. It is very important for the programmers to maintain the coding standards otherwise the code will be rejected during code review.

 

Writing an efficient software code requires a thorough knowledge of programming. This knowledge can be implemented by following a coding style which comprises several guidelines that help in writing the software code efficiently and with minimum errors. These guidelines, known as coding guidelines, are used to implement individual programming language constructs, comments, formatting, and so on. These guidelines, if followed, help in preventing errors, controlling the complexity of the program, and increasing the readability and understandability of the program.

The developers should be aware of the coding guidelines before starting a software project. Moreover, coding guidelines should state how to deal with the existing code when the software incorporates it or when maintenance is performed.

If coding guidelines are used in a proper manner, errors can be detected at the time of writing the software code. Such detection in early stages helps in increasing the performance of the software as well as reducing the additional and unplanned costs of correcting and removing errors. Moreover, if a well-defined coding guideline is applied, the program yields a software system that is easy to comprehend and maintain.

 

Structured programming:

A structured programming language facilitates or enforces structured programming practices. A program is called structured when it uses only the sequence, selection and iteration types of constructs and is modular.

Structured programming is facilitated, if the programming language being used supports single-entry, single-exit program constructs such as if-then-else, do-while etc. Thus an important feature of structured programs is the design of good control structures.

Besides the control structure aspects, the term structured program is being used to denote a couple of other program features as well. A structured program should be modular. We use structured programming because it allows the programmer to understand the program easily.

Structured programming encourages dividing an application program into a hierarchy of modules or autonomous elements, which may, in turn, contain other such elements. Within each element, code may be further structured using blocks of related logic designed to improve readability and maintainability. These may include case, which tests a variable against a set of values repeat, while and for, which construct loops that continue until a condition is met.

Structured programming encourages the developer to use subroutine and loops instead of using simple jumps in the code, thereby bring clarity in the code and improving its efficiency. Structured programming also helps programmer to reduce coding time and organize code properly.

The main advantage of writing structured program compared to unstructured program is that programmer commit less number of errors while using structured if-then-else and do-while statements. Besides being less error prone, structured program are normally more readable, easier to maintain and require less effort to develop compared to unstructured programs.

 

Verification and validation:

In software testing, verification and validation are the processes to check whether a software system satisfies the specifications and that it fulfills its intended purpose or not.

Verification: Are we building the product right?

Validation: Are we building the right product?

 

Verification:

Verification is a process of determining if the software is designed and developed as per the specified requirements. It is the process of determining whether the output of one phase of software development conforms to that of its previous phase.

Verification is the process of evaluating a system or component to determine whether the products of a given development phase satisfy the conditions imposed at the start of that phase. It is the process of evaluating the intermediary work products of a software development lifecycle to check if we are in the right track of creating the final product. 

Verification in Software Testing is a process of checking documents, design, code, and program in order to check if the software has been built according to the requirements or not.

Verification is the process to ensure that whether the product that is developed is right or not. The verification process involves activities like reviews, walkthroughs and inspection. 

 

Validation:

Validation is the process of checking if the software (end product) has met the client’s true needs and expectations.  It is the process of checking the validation of product. Validation helps to determine if the software team has built the right product. It is validation of actual and expected product. Validation is the dynamic testing. 

Validation in Software Engineering is a dynamic mechanism of testing and validating if the software product actually meets the exact needs of the customer or not.

Validation is conducted after the completion of the entire software development process. It checks if the client gets the product they are expecting. Validation focuses only on the output; it does not concern itself about the internal processes. 

 

Difference between verification and validation:

Verification

Validation

Verification means Are we building the product right?

Validation means Are we building the right product?

It is a process of checking if a product is developed as per the specifications.

It is a process of ensuring that the product meets the needs and expectations of customers.

Quality assurance team does verification.

The software testing team along with the QA team does validation.

Concerned with phase containment of  errors

Aim is to make final product error free

Activities involved here are reviews, inspection, and walkthroughs.

Activities involved here is black box testing, white box testing, acceptance testing.

It is a static method of checking documents and files.

It is a dynamic process of testing the real product.

It does not require executing the code.

It involves code execution to test the usability and functionality of the end product.

Evaluates the intermediary products to check whether it meets the specific requirements of the particular phase.

Evaluates the final product to check whether it meets the business needs.

Verification process includes checking of documents, design, code and program

Validation process includes testing and validation of the actual product.

Error, Fault and Failure

The term error, fault and failure are often used interchangeable, but do have different meanings. In software, an error is usually a programmer action or omission that results in a fault. A fault is a software defect that causes a failure, and a failure is the unacceptable departure of a program operation from program requirements.

Failure is an event; fault is a state of the software caused by an error.

 

An error characterizes a particular state of a system, a failure is a particular event namely the transition from correct service delivery to incorrect service. An error may cause a fault to be injected into the application, and a fault may cause failure when the application is executed.

A single error may cause many faults. For example, a wrong algorithm is applied in multiple modules of the system and that causes multiple faults in the system. Similarly, a single fault may cause many failures in repeated executions. A faulty system would fail many times in repeated executions until the problem is fixed or patched. 

Error:

An Error is a human action or mistake when developing/using or operating a system or the software application. Human errors and mistakes introduce or inject faults into the system.

It is an outcome of human mistakes that leads to an inappropriate result from the working product. Error refers to the difference between the actual observed output and the correct expected output. Error is a discrepancy between a computed, observed or measured value/condition and the true specified or theoretically correct value/condition.

An error is a mistake, misconception, or misunderstanding on the part of a software developer. In the category of the developer, we include software engineers, programmers, analysts, and testers. For example, a developer may misunderstand a design notation, or a programmer might type a variable name incorrectly, leads to an Error. The error normally arises in software; it leads to a change in the functionality of the program.

 

Fault:

The result of an error being made is a fault. The fault is a condition that causes the software to fail in performing its required functionality. It is a symptom of an error in the software. It is something that is wrong in the software. Faults are also known as defects or bugs.

An incorrect step, process or data definition in a computer program causes the program to perform in an unintended or unanticipated manner. A fault is introduced into the software as the result of an error. It is an anomaly in the software that may cause it to behave incorrectly, and not according to its specification.

Failure:

Failures are caused by faults in the software. Failure is the inability of the program to perform its required function. As a result, the product is not able to perform the activity according to its specification. Failure occurs when fault is present in the system.

 

 

Debugging:  

 Debugging is the process of finding bugs i.e. error in software or application and fixings them. It is a systematic process of spotting and fixing the number of bugs, or defects, in a piece of software so that the software is behaving as expected.

It is the process of detecting and removing of existing and potential errors (also called as ‘bugs’) in a software code that can cause it to behave unexpectedly or crash. To prevent incorrect operation of a software or system, debugging is used to find and resolve bugs or defects. 

Debugging refers to identifying, analyzing and removing errors. In software development, the debugging process begins when a developer locates a code error in a computer program and is able to reproduce it. Debugging is part of the software testing process and is an integral part of the entire software development lifecycle.

Debugging gets started when we start writing the code for the software program. It works stepwise, starting from identifying the errors, analyzing followed by removing the errors. Whenever a software fails to deliver the result, we need the software tester to test the application and solve it.

Debugging refers to finding bugs, analyzing, and fixings them. To debug a program, user has to start with a problem, isolate the source code of the problem, and then fix it. A user of a program must know how to fix the problem as knowledge about problem analysis is expected. When the bug is fixed, then the software is ready to use. Debugging tools (called debuggers) are used to identify coding errors at various development stages. They are used to reproduce the conditions in which error has occurred, then examine the program state at that time and locate the cause.

 

 

Testing:

Software testing is the process of finding errors in the developed product. It is the process of evaluating and verifying that a software product or application does what it is supposed to do. The benefits of testing include preventing bugs, reducing development costs and improving performance. 

Software testing is evaluation of the software against requirements gathered from users and system specification. It is an activity performed to identify errors so that error can be removed to obtain a product with greater quality.

Software testing is a process, to evaluate the functionality of a software application with an intent to find whether the developed software met the specified requirements or not and to identify the defects to ensure that the product is defect-free in order to produce a quality product.

 

Types of Software Testing Technique:

Software testing techniques can be majorly classified into two categories  

     ·        Black box testing

     ·        White box testing

 

Black box testing:

Black box testing is a technique of software testing which examines the functionality of software without knowing into its internal structure or coding. It is the method that does not consider the internal structure, design, and product implementation to be tested.

In Black-box testing, a tester doesn’t have any information about the internal working of the software system. The Black Box only evaluates the external behavior of the system. The inputs received by the system and the outputs or responses it produces are tested.

This testing approach focuses on the input that goes into the software, and the output that is produced. Black box testing involves testing a system with no prior knowledge of its internal workings. The testing team does not cover the inside details such as code, server logic, and development method.

Black box testing involves testing against a system where the code and paths are invisible. It is a process of checking the functionality of an application as per the customer requirement. The source code is not visible in this testing; that’s why it is known as black-box testing.

 

Black box testing is based on the requirements and checks the system to validate against predefined requirements. The testing is done without the internal knowledge of the products. Black-box testing is commonly known as behavioral testing, since we follow the behavior of the overall design.

In black box testing, test cases are designed from an examination of the input/output values only and no knowledge of design or code is required. For this reason, black box testing is also known as functional testing.

 

Types of Black Box Testing:

 There are three types of black-box testing namely: functional testing, non-functional testing, and regression testing.

 

Functional Testing:

This is a type of black box testing which deals with the functional requirements or specifications of a system.  Here, different actions or functions of the system are being tested by providing the input and comparing the actual output with the expected output.

Functional testing is concerned only with the functional requirements of a system and covers how well the system executes its functions. Software testers are responsible for carrying out this test.

 

Non-Functional Testing:

This black box testing type is not related to testing of specific functionality. Black box testing can check additional aspects of the software, beyond features and functionality.

 Non functional testing is concerned with the non-functional requirements and is designed specifically to evaluate the readiness of a system according to the various criteria which are not covered by functional testing.

Apart from the functionalities of the requirements, there are several non-functional aspects that are required to be tested to improve the quality and performance of the application. It is solely focused on non-functional requirements like usability, scalability and performance.

 

Regression Testing:

Regression Testing is done after code fixes, upgrades or any other system maintenance to check the new changes has not affected any existing functionality. The motive is to examine the new code and its effect on the existing code.

 

Techniques of Black Box Testing:

In order to systematically test a set of functions, it is necessary to design test cases. Testers can create test cases from the requirement specification document using the following Black Box Testing techniques:

1.     Equivalence Partitioning

2.     Boundary Value Analysis

3.     State Transition Testing

4.     Decision Table Testing

5.     Graph-based testing

6.     Error Guessing

7.     Comparison Testing

 

Equivalence Partitioning:

This technique is also known as Equivalence Class Partitioning (ECP).  In this technique, input values to the system or application are divided into different classes or groups based on its similarity in the outcome.

 

Hence, instead of using each and every input value, we can now use any one value from the group/class to test the outcome. This way, we can maintain test coverage while we can reduce the amount of rework and most importantly the time spent.

 

Boundary Value Analysis:

Boundary value testing is focused on the values at boundaries.. The two ends, the inner and the outer limits are considered in this type of testing. We set a boundary value lower or higher than the actual limit to check the behavior of our system in both conditions.

Boundary value analysis tests the software with test cases with extreme values of test data. It is used to identify the flaws or errors that arise due to the limits of input data. This technique determines whether a certain range of values are acceptable by the system or not

 

State Transition Testing:

State Transition Testing is a technique that is used to test the different states of the system under test. The state of the system changes depending upon the conditions or events. If there are different responses during transition from one state to another then state transition testing can be incorporated. 

 

This testing technique uses the inputs, outputs, and the state of the system during the testing phase. It checks the software against the sequence of transitions or events among the test data.

Based on the type of software that is tested, it checks for the behavioral changes of a system in a particular state or another state while maintaining the same inputs.

 

 

Decision Table Testing:

This approach creates test cases based on various possibilities. It considers multiple test cases in a decision table format where each condition is checked and fulfilled, to pass the test and provide accurate output. It is preferred in case of various input combinations and multiple possibilities.

If the results are obtained depending on certain conditions it comes under Decision table testing. If the conditions are combined they form rules. The outputs of these rules are formed and the test cases are structured.

 

 

Graph-Based Testing:

 

It is similar to a decision-based test case design approach where the relationship between links and input cases are considered.

 

 

 

Error Guessing Technique:

 

Error Guessing is a technique based on guessing the errors that can stay in the application. This method of designing test cases is about guessing the output and input to fix any errors that might be present in the system. It depends on the skills and judgment of the tester. There’s no specific set of rules to test the behavior of a system with this technique.

 

It can help to look for various faults which systematic techniques may fail to detect. The method almost always depends on the tester’s prior experience and their foresight to guess where defects can occur in the future.

 

 

Comparison testing:

 

In this method, different independent versions of the same software are used to compare to each other for testing.

 

 

White Box testing:

White box testing is a testing technique which evaluates the code and the internal structure of a program. White-box testing is the detailed investigation of internal logic and structure of the code.

In order to perform white-box testing on an application, a tester needs to know the internal workings of the code. White box testing involves testing the product’s underlying structure, architecture, and code to validate input-output flow and enhance design, usability, and security. 

Designing white box test cases require a thorough knowledge of the internal structure of a program, and therefore white box testing is also called structural testing.

The White Box Test method is the one that looks at the code and structure of the product to be tested and uses that knowledge to perform the tests. White box testing is also known as open box testing, glass box testing, structural testing, clear box testing, and transparent box testing

 

Difference between Black-box Testing and White-Box testing:

 

 

Black Box Testing

White Box Testing

1

Black Box Testing considers the external behavior of the system; the internal working of the software is not taken into account.

White Box Testing is used to test a software taking into consideration its internal functioning.

2

Implementation of code is not needed for black box testing.

Code implementation is necessary for white box testing.

3

It is mostly done by software testers.

It is mostly done by software developers.

4

Black Box Test is not considered for algorithm testing.

White Box Test is well suitable for algorithm testing.

5

It can be referred as outer or external software testing.

It is the inner or the internal software testing.

6

It is functional test of the software.

It is structural test of the software.

7

Black Box test doesn’t require programming knowledge

White Box test requires programming knowledge.

8

It is the behavior testing of the software.

It is the logic testing of the software.

9

It is also known as data-driven testing, functional testing and closed testing.

It is also known as clear box testing, code-based testing, structural testing, and transparent testing.

10

It is least time consuming.

It is most time consuming.

 

 

 

Levels of testing:

Testing is used to detect faults introduced during specification and design stages as well as coding stages. Due to this, different levels of testing are used in the testing process. Each level of testing aims to test different aspects of the system. The basic levels of testing are:

 

    ·        Unit testing

    ·        Integration testing

    ·        System testing

    ·        Acceptance testing

 


        Levels of testing

 

 

Unit Testing:

Unit testing is the process of checking small pieces of code to ensure that the individual parts of a program work properly on their own. This involves the tests carried out on modules, which make up a system. During unit testing, the individual components or units of a program are tested. Unit testing focuses first on the modules, independently of one another, to locate errors.

Unit testing is the process of taking a module and running it in isolation from the rest of the software product by using prepared test cases and comparing the actual results with the results predicted by the specifications and design of the module.

In this level, different modules are tested against the specification produced during design for the modules. Unit testing is essentially for verification of the code produced during the code phase. That is, the goal of this testing is to test the internal logic of the modules. Due to its close association with coding, the coding phase is frequently called “coding and unit testing”.

The primary objective of executing the unit testing is to confirm the unit components with their performance.

 

Integration Testing:

Once we are successfully implementing the unit testing, we will go integration testing. In this level, many unit-tested modules are combined into subsystems, which are then tested. The goal of this testing level is to see if the modules can be integrated properly.

Integration testing ensures that an entire, integrated system meets a set of requirements. The purpose of executing the integration testing is to test the statement’s accuracy between each module.

System Testing:

Whenever we are done with the unit and integration testing, we can proceed with the system testing. Here the entire software is tested. The reference document for this process is the requirements document. The goal is to see if the software meets its requirements.

The purpose of system testing is to validate an application’s accuracy and completeness in performing the functions as designed.

 

Acceptance Testing: 

Acceptance testing is performed using real data of the client to demonstrate that software is working satisfactorily. Testing here focuses on the external behavior of the system. Internal logic is not important for the testing. Hence, functional testing is performed at this level.

It is a kind of testing conducted to ensure whether the requirement of the users are fulfilled prior to its delivery and the software works correctly in the user’s working environment.

 

The testing can be conducted at various stages of software development. The levels of testing along with their corresponding software development phases are shown by the following diagram:

 

 

Leave a Comment