Debug: Exception Handling | OpenTAP

Debug: Exception Handling | OpenTAP


Debug: Exception Handling | OpenTAP


Content

4.64 -> hello my name is chun feng in this  video we are going to be looking at  
9.6 -> OpenTAP exception handling we will start  by showing you how to catch an assertion and  
15.36 -> lock the messages in different levels which are  debugs info warning and error so let's get started  
26.08 -> here i have created a new operand type projects  
29.6 -> then i will create a test step that performs  simple divisions first let's add two properties  
36.16 -> numerators and denominators and assign them  with their different values in the constructors
46.56 -> here in the run method we perform division in  try cache if the division performs successfully  
53.12 -> we will upgrade the verdict to pass if the verdict  fail we would have handled the error in the cache  
60.72 -> by upgrading the verdict to error after the  try cache it will proceed to run the child step  
68.16 -> okay now let's build and run this we add  our division test step into the test plan  
75.28 -> we keep the numerators and denominators as  default now we run the test plan everything good  
83.2 -> the test plan is passed but now we switch the  denominator to 0 and see what the result is
91.68 -> it shows us error because we have  updated errors verdict in the cache block  
96.08 -> however as a user we want to  know what the actual error is  
100.24 -> so let's see what we can do for that we  add debug log to see what the values of  
105.44 -> numerators and denominators are also we can log  warning to want the user when denominator is zero  
112.88 -> inside the try block we can lock the answer as  info and finally lock the error when it's failed
122.88 -> ok now let's build and run this first  let us run the test which will pass  
129.92 -> and we can see the result in the information log  in the log panel below now we run the test which  
135.84 -> will fail we can see the error message in red and  the warning message in yellow means well this is  
143.6 -> the debug message these messages can be served as  debugging tools and enhance the user experience  
151.52 -> now we are going to see how the child  steps behave in the current condition  
156.48 -> what we just saw is the child step runs even  if the parent have step run into an error  
162.8 -> this behavior might not be  suitable for all the use cases  
167.12 -> if you want to avoid running the child  step when the parent test step is error out  
171.44 -> we can abort the whole test in the catch  block let's see the changes in the behavior  
177.84 -> the child step didn't runs and the tab plan is  supported let's summarize what we have learned  
182.4 -> today first we learned how to do exception  handling next logging in different levels  
191.36 -> and lastly about the test plan in the error  conditions that's all for this video enjoy OpenTAP

Source: https://www.youtube.com/watch?v=8Ukmo7jG9EI