Knowing a test passed is clear, but understanding why a test failed can be more complicated.
Start by outputting relevant and valuable data to your test results. The key is identifying what provides value, and what creates noise.
Value-added items can:
- Help identify the reason for the failure more quickly
- Assist reproducing the issue
- Provide useful information for logging a defect
- Illustrate areas of possible concern or application inconsistencies
- Produce meaningful data for overall testing metrics
Often when optimizing a test suite, exception handlers and/or event handlers are incorporated. Logging relevant information to the test results upon handling an event or exception, can identify unexpected dialogs, text, or delays in application reaction time.
Simply logging a failure or handled exception without detail greatly limits the value provided by the reports, and can cause delays or oversights identifying potential defects.
testSettings.logScreenshotOnFail = True
testSettings.logScreenshotOnError = True
test.warning("Warning on initial attempt: " + err);
testSettings.logScreenshotOnFail = False
testSettings.logScreenshotOnError = False
Notice the test.warning message, logging a warning, but not failure to your test results in the event the exception was handled. You can identify a potential issue, or intermittent problem, which might otherwise cause a unnecessary test script failure (if the the catch was not incorporated), or go unnoticed if the exception was handled but not properly logged.
The testSettings.logScreenshotOnFail or testSettings.logScreenshotOnError functions, set to True, capture a screenshot when either a verification point failure or a script error occurr.
Finally, capturing object-level properties and values may pinpoint discrepancies between expected and actual results.
Your report now contains data pertaining to handled exceptions, screenshot evidence of the potential issue as well as the object-level properties and values at the exact moment the issue occurred. Compare that to a simple Object Not Found error, and you’ve already taken strides to increase your test results value with a few simple adjustments.
For more information on the above topics, see: