2-Software Testing-Introduction
2-Software Testing-Introduction
of software testing
Static Testing Dynamic Testing
Testing done without executing the program Testing done by executing the program
This testing does verification process Dynamic testing does validation process
Static testing is about prevention of defects Dynamic testing is about finding and fixing
the defects
Static testing gives assessment of code and Dynamic testing gives bugs/bottlenecks in
documentation the software system.
Static testing involves checklist and process Dynamic testing involves test cases for
to be followed execution
This testing can be performed before Dynamic testing is performed after
compilation compilation
Static testing covers the structural and Dynamic testing covers the executable file
statement coverage testing of the code
Cost of finding defects and fixing is less Cost of finding and fixing defects is high
Return on investment will be high as this Return on investment will be low as this
process involved at early stage process involves after the development
phase
More reviews comments are highly More defects are highly recommended for
recommended for good quality good quality.
Requires loads of meetings Comparatively requires lesser meetings
Types of software testing (verification & validation)
Verification and Validation are two measures used to check that the
software product meets the requirements specifications. Together
they help improve software quality.
Types of software testing
(verification & validation)
White box tests are named so as the source code is used during
software testing. White box tests are also known as structural tests
as they test small parts (structures) of the software product. Unit
tests and integration tests fall under these tests.
Black box tests are named so as the source code is not used during
software testing. Instead the executable binary machine code is
used. Black box tests are further divided into functional and non
functional tests. Non functional tests are further divided into
performance, security, usability etc. tests.
Regression tests are done for both white box as well as black box
tests.
Verification & validation and associated software testing
types
Verification & Validation
Requirement specification reviews are done after these artifacts get completed.
Software testers or business analysts review the requirement specifications
for completeness, ambiguity and errors. If any errors or incompleteness is
found then it is rectified.
Software design reviews are done to check if the software design is correct as
per requirement specifications. Software design reviews also include
reviewing software component structure. If large classes were with many
methods are designed then it will lead to difficult to understand source code.
Similar structural problems can be found during design reviews. The
identified design problems will need to be rectified
.
Source code reviews are done to check for dead code, wrong implementation
of business logic etc. If any of these defects are found then they are
rectified.
Code walkthroughs are also used for source code checking. Here the
developer presents his/her source code in front of other project team
members. Team members review the source code and find any defects are
there in the code. Software developer later rectifies those defects.
Unit testing
Unit testing is done after a class or component is
constructed. Each class implements some business
logic. The source code in the class is checked to verify if
the business logic is implemented properly.
• int boxarea() {
• return x*y;
• }
• }
Example Test class
package testTry;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class boxTest {
Box b;
@BeforeEach
@Test
void test() {
assertEquals(12, b.boxarea());
}
}
Unit Testing Example
class addition {
public boolean adding (integer one, integer two){
if one >= 1 and one <= 100 and two >= 1 and two <= 100 {
integer x = one + two;
print (x);
return true;
}
else
return false;
}
}
The above class implements a business logic which needs to be tested. The test code can be
as following:
class testAddition {
public method void testAdding () {
boolean x = addition.adding(-3, 5);
}
}
The above test case is a negative test case as the expected result should fail. Using
positive and negative tests, we can find out if the business logic works fine.
For positive and negative testing, this test class can be provided with various values and
these values will be passed to the class under test through parameters.
Unit Test: Example
In the above example, you will also need to find out if the mentioned record has been
deleted from the database.
Database operations work on the principle of first searching
a particular record and then doing database operations.
If a particular record is changed or deleted after a test then
the same test script will not work next time.
Since the particular database record was changed after
execution of test script the first time, next time you may
need to change test script.