Black-Box Testing in Python
Before starting this part, I would recommend you guys to go through Python Basics. You can try our Python Chapters for that.
However, if you already did that, then just skip it and move forward.
Testing in Python – A Must Know Guide
Here are some previous parts of this series-
In short we can define Black-Box Testing as..
Black-box testing is a method of software testing that tests the functionality of an application.”
What Is It?
– Test suites can be designed even without looking at the code.
– Can be also done by somebody else rather than the developer. (Generally by QA Team)
– It can avoid the inherent biases of the developer by exposing potential bugs more easily.
– As I said earlier in this approach testing is designed without any knowledge of the code. Thus, it can be reused even if the functionality or the development changes.
Black-Box Test Suites
Black-Box Test Suites can also be defined as possible test cases for checking the accuracy of your code. It generally contains these two possible ways..
– The possible paths through the specification.
– The possible boundary cases.
Undoubtedly many – if not all – of the listed tests look like they would be pretty good for testing the functionsize. However, I want you to think critically about the way size is specified – including possible boundary cases – and pick a set of tests that adequately and fully tests all paths and boundary conditions. Be sure the set of tests you pick does not have extraneous, useless, or repetitive tests.
(If you still didn’t get the pith of if; Don’t worry. I did include some examples and explanations in this article to make you familiar with it. Let’s go through it.)
- Suppose, we want the base and exponent related functionality. So-
→ def sqrt (base, exp):
Now for this functionality, our assumptions will be like..
→ Assume base and exp can be any type (int or float)
→ exp == 0 then return 1
→ exp > 0 then return (base * (base)^(exp-1))
Now, we have logics ready. So let’s make a list of all possible paths for detailed specification.
→ List down all the boundary cases.
→ Very small and very large numbers.
→ Some cases like empty list, singleton list etc.
So far, so good. For this situation, our test suites will be like..
base exp Result 0 0 Undefined 0 2 0 0 2.5 0 5 0 1 3.5 0 1 6 4.25 2028.3496 14 3 2744
I took several different combinations of inputs and their respective desired results. If I got the problem in any of the case while testing then I can directly move to the code and look for the particular type of functionality inappropriateness that causing me such error and will try to fix it and move forward.
def size(aSet): """ aSet is a collection of objects, which might be empty. Objects are assumed to be of the same type. """
Explanation and Test Suite Path
Here is a set of possible test cases to include in a black box test suite.
→ Empty Set
→ Set of Size 1
→ Se of Size Greater Than 1
That’s all from Black-Box Testing in Python. Keep visiting for more PY stuffs.
Till next, Keep Sharing & Tweaking! 💡 💡