Question: Exception Handling As a test engineer, you are responsible for finding and handling exceptions in the code. Today, your surpervisor gives you a task to
Exception Handling
As a test engineer, you are responsible for finding and handling exceptions in the code. Today, your surpervisor gives you a task to catch the exception in a function. He says that the function is strictly confidential and you do not have the access to the source code. You job is to call the function with different inputs and catch the exception if it occurs.
The function is called blackbox and it takes one argument command. The command can be an integer range from The function returns nothing if it run successfully. If the function fails, it raises an exception. You need to create a list exceptionreport to collect all the running results with command from The result should be a string with the following format:
If the function raises an ValueError exception, the result should be "Value Error"
If the function raises an TypeError exception, the result should be "Type Error"
If the function raises an ZeroDivisionError exception, the result should be "ZeroDivision Error"
If the function raises an IndexError exception, the result should be "Index Error"
If the function raises an other exception, the result should be "Abnormal Error"
If the function runs successfully, the result should be "Success"
Here are the example of the expected results:
blackbox # raises IndexError which should be added to the list exceptionreport
The setup code gives the following variables:
NameTypeDescriptionblackboxfunctionfunction that you need to test
Your code snippet should define the following variables:
NameTypeDescriptionexceptionreportlistlist that collects the exception messages
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
