Logging and Reporting Mechanisms Flashcards
(Within the TAS) One way of implementing the Test Execution Layer:
Writing test automation scripts from scratch.
Mention an example of test execution library in Python:
pytest
can run tests and report their results.
Unit test libraries
Pytest default tests selection and execution:
Looks for all files (in the current directory or its subdirectories.) which matches the specified pattern and then executes them.
Main pytest flags that may modify its behavior:
- Verbose mode: pytest -v
- Quiet mode: pytest -q
- Generate a report in HTML format: pytest –html=report.html
Tests marks that can be put before a test definition so that pytest give it a special treatment.
- @pytest.mark.skip: pytest will not run the test.
- @pytest.mark.xfail: the test is expected to fail.
When a automated script test fails, what limitations does it have an error message?
- is wholly insufficient.
- frequently has no context
- may have nothing to do with the actual failure which stopped the execution of the test.
What is Logging?
a way to track events that occur during execution.
How the Logging gets done?
- may be done before a step is taken and after a step is taken
- may include the data that was used in the step
- may include the behavior that occurred as a result of the step.
- can help a test analyst determine quickly if the failure was caused by the SUT or not.
If eventually, the project could reach a big size then the logging will be required.
It is more effective and efficient to start logging robustly from the start.
At any point in an automated script, the automator may add logging calls to report out any information like:
- general information for later tracing the test
- warnings about something that happened that does not rise to the level of a failure
- actual errors
Five different levels of messages in Python (DIWEC: From lowest to highest levels):
- DEBUG
- INFO
- WARNING
- ERROR
- CRITICAL
DEBUG level purpose:
for diagnosing problems
INFO level purpose:
for confirmation that things worked
WARNING level purpose:
something unexpected occurred, a potential problem