Table of contents:
Software testing is an approach to test our own software by adding some cases that would check whether our code works properly on all possible conditions.
We use Software testing to check whether:
- The code block works as expected
- The code gives proper exception as expected when something unacceptable occurs
- The code is resilient and robust enough to handle high traffic (
Scalable
) - The new update in our code modifies previous expected behaviors (
Regression
)
Let us take an example of a function which takes a number and divides it by 2 if it is an even and multiplies by 2 if it is 2.
def multiply_divide(number):
if number%2==0:
return int(number/2)
return number * 2
for the above code snippet, we can check the following:
- try some even number and see if it results in half of the provided number.
- try some odd number and see if it results in double of the provided one.
- check if it handles exception if it is fed with wrong data type.
In python, assert keyword plays a vital role in testing the code snippet. If the
condition is met or True
in the assert
statement, then the code will run
otherwise, Assertion Error
will be raised.
Example:
assert multiply_divide(4)==2 # code continues to run
assert multiply_divide(4)==8 # AssertionError
Tests can be classified into different types based on its category.
-
Functional: used to check the code snippets
Unit testing
: testing specific function or a part of a codeIntegration testing
: testing whether different parts of a code integrates with each otherSystem testing
: testing whether the system works properly and as expectedAcceptance testing
: testing whether the solution is acceptable to clients
-
Non-Functional: used to check the software behavior
Performance testing
: used to check if the solution is optimumScalability testing
: used to check if the solution is scalableReliability testing
: used to check if the solution is reliableSecurity testing
: used to check if the solution is secure
-
Maintenance: used to test if new update behavior
Regression testing
: used to check if an update modifies existing behaviorSanity testing
: used to check if the bugfix worksSmoke testing
: used to quick check the status after a new build
There are different testing approach depending on who is testing the software. Sometimes, it is better to test the software by those people who knows what is being done with the software whereas, it is better to test by some other people sometimes to know whether people can see the solution from another angle.
Black-box testing is a software testing method where the tester evaluates the functionality of an application without knowing the internal code, structure, or implementation. The focus is entirely on inputs, outputs, and the expected behavior of the software.
White-box testing is a software testing method where the tester examines the internal structure, design, or code of the application to ensure that it works as expected. It is also known as clear-box testing, glass-box testing, or structural testing.
Grey-box testing is a software testing method that combines aspects of both black-box and white-box testing. The tester has partial knowledge of the internal workings of the software, which is used alongside functional testing to improve test coverage and effectiveness.