Welcome to Avocado¶
Avocado is a set of tools and libraries to help with automated testing.
One can call it a test framework with benefits. Native tests are written in
Python and they follow the unittest
pattern, but any executable can
serve as a test.
How does it work?¶
You should first experience Avocado by using the test runner, that is, the command line tool that will conveniently run your tests and collect their results.
To do so, please run avocado
with the run
sub-command followed by a
test reference, which could be either a path to the file, or a recognizable
name:
$ avocado run /bin/true
JOB ID : 3a5c4c51ceb5369f23702efb10b4209b111141b2
JOB LOG : $HOME/avocado/job-results/job-2019-10-31T10.34-3a5c4c5/job.log
(1/1) /bin/true: PASS (0.04 s)
RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME : 0.15 s
You probably noticed that we used /bin/true
as a test, and in accordance
with our expectations, it passed! These are known as simple tests, but there
is also another type of test, which we call instrumented tests.
See also
See more at Test types to understand Avocado’s test types.
Why should I use?¶
Multiple result formats¶
A regular run of Avocado will present the test results on standard output, a nice and colored report useful for human beings. But results for machines can also be generated.
Check the job-results folder ($HOME/avocado/job-results/latest/
) to see the
outputs.
Currently we support, out of box, the following output formats:
- xUnit: an XML format that contains test results in a structured form, and are used by other test automation projects, such as jenkins.
- JSON: a widely used data exchange format. The JSON Avocado plugin outputs job information, similarly to the xunit output plugin.
- TAP: Provides the basic TAP (Test Anything Protocol) results, currently in v12. Unlike most existing Avocado machine readable outputs this one is streamlined (per test results).
Note
You can see the results of the lastest job inside the folder
$HOME/avocado/job-results/latest/
. You can also specify at the command line
the options --xunit
, --json
or --tap
followed by a filename.
Avocado will write the output on the specified filename.
When it comes to outputs, Avocado is very flexible. You can check the various output plugins. If you need something more sophisticated, visit our plugins section.
Sysinfo data collector¶
Avocado comes with a sysinfo plugin, which automatically gathers some system information per each job or even between tests. This is very helpful when trying to identify the cause of a test failure.
Check out the files stored at $HOME/avocado/job-results/latest/sysinfo/
:
$ ls $HOME/avocado/job-results/latest/sysinfo/pre/
'brctl show' hostname modules
cmdline 'ifconfig -a' mounts
cpuinfo installed_packages 'numactl --hardware show'
current_clocksource interrupts partitions
'df -mP' 'ip link' scaling_governor
dmesg 'ld --version' 'uname -a'
dmidecode lscpu uptime
'fdisk -l' 'lspci -vvnn' version
'gcc --version' meminfo
For more information about sysinfo collector, please visit the Section “Collecting system information” on Avocado’ User Guide.
Job Replay and Job Diff¶
In order to reproduce a given job using the same data, one can use the
--replay
option for the run
command, informing the hash id from the
original job to be replayed. The hash id can be partial, as long as the
provided part corresponds to the initial characters of the original job id and
it is also unique enough. Or, instead of the job id, you can use the string
latest and Avocado will replay the latest job executed.
Example:
$ avocado run --replay 825b86
JOB ID : 55a0d10132c02b8cc87deb2b480bfd8abbd956c3
SRC JOB ID : 825b860b0c2f6ec48953c638432e3e323f8d7cad
JOB LOG : $HOME/avocado/job-results/job-2016-01-11T16.18-55a0d10/job.log
(1/2) /bin/true: PASS (0.01 s)
(2/2) /bin/false: FAIL (0.01 s)
RESULTS : PASS 1 | ERROR 0 | FAIL 1 | SKIP 0 | WARN 0 | INTERRUPT 0
JOB TIME : 0.11 s
JOB HTML : $HOME/avocado/job-results/job-2016-01-11T16.18-55a0d10/html/results.html
Avocado Diff plugin allows users to easily compare several aspects of two given jobs. The basic usage is:
$ avocado diff 7025aaba 384b949c
--- 7025aaba9c2ab8b4bba2e33b64db3824810bb5df
+++ 384b949c991b8ab324ce67c9d9ba761fd07672ff
@@ -1,15 +1,15 @@
COMMAND LINE
-/usr/bin/avocado run sleeptest.py
+/usr/bin/avocado run passtest.py
TOTAL TIME
-1.00 s
+0.00 s
TEST RESULTS
-1-sleeptest.py:SleepTest.test: PASS
+1-passtest.py:PassTest.test: PASS
...
Extensible by plugins¶
Avocado has a plugin system that can be used to extend it in a clean way. The
avocado
command line tool has a builtin plugins
command that lets you
list available plugins. The usage is pretty simple:
$ avocado plugins
Plugins that add new commands (avocado.plugins.cli.cmd):
exec-path Returns path to Avocado bash libraries and exits.
run Run one or more tests (native test, test alias, binary or script)
sysinfo Collect system information
...
Plugins that add new options to commands (avocado.plugins.cli):
remote Remote machine options for 'run' subcommand
journal Journal options for the 'run' subcommand
...
For more information about plugins, please visit the Plugin System section on the Avocado’s User Guide.
Utility libraries¶
When writting tests, developers often need to perform basic tasks on OS and end up having to implement these routines just to run they tests.
Avocado has more than 40 utility modules that helps you to perform basic operations.
Bellow a small subset of our utility modules:
- utils.vmimage: This utility provides a API to download/cache VM images (QCOW) from the official distributions repositories.
- utils.memory: Provides information about memory usage.
- utils.cpu: Get information from the current’s machine CPU.
- utils.software_manager: Software package management library.
- utils.download: Methods to download URLs and regular files.
- utils.archive: Module to help extract and create compressed archives.
How to install¶
It is super easy, just run the follow command:
$ pip3 install --user avocado-framework
Note
For more methods, please visit the Install Guide section on our oficial documentation.
Documentation¶
Please see Contents for full documentation, including installation methods, tutorials and API.
Bugs/Requests¶
Please use the GitHub issue tracker to submit bugs or request features.
Changelog¶
Consult the Changelog file for fixes and enhancements of each version.
License¶
Except where otherwise indicated in a given source file, all original contributions to Avocado are licensed under the GNU General Public License version 2 (GPLv2) or any later version.
By contributing you agree that these contributions are your own (or approved by your employer) and you grant a full, complete, irrevocable copyright license to all users and developers of the Avocado project, present and future, pursuant to the license of the project.
Build and Quality Status¶
Contents:
Quick Start
Guides
- Avocado User’s Guide
- Avocado Test Writer’s Guide
- Writing a Simple Test
- Writing Avocado Tests with Python
- Basic example
- Multiple tests and naming conventions
- Convenience Attributes
- Test statuses
- Test methods
- Turning errors into failures
- Turning errors into cancels
- Saving test generated (custom) data
- Accessing test data files
- Accessing test parameters
- Running multiple variants of tests
unittest.TestCase
heritage- Running tests under other
unittest
runners - Setup and cleanup methods
- Running third party test suites
- Fetching asset files
- Test Output Check and Output Record Mode
- Test log, stdout and stderr in native Avocado modules
- Setting a Test Timeout
- Skipping Tests
- Cancelling Tests
- Docstring Directives
- Declaring test as NOT-INSTRUMENTED
- Declaring test as INSTRUMENTED
- (Deprecated) enabling recursive discovery
- Categorizing tests
- Python
unittest
Compatibility Limitations And Caveats - Environment Variables for Tests
- SIMPLE Tests BASH extensions
- SIMPLE Tests Status
- Job Cleanup
- Docstring Directives Rules
- Signal Handlers
- Wrap Up
- Advanced logging capabilities
- Test parameters
- Multiplexer concept
- Utility Libraries
- Subclassing Avocado
- Avocado Contributor’s Guide
Avocado Plugins
Our Releases
- Avocado Releases
- How we release Avocado
- Long Term Stability Releases
- Regular Releases
- 74.0 Home Alone
- 73.0 Pulp Fiction
- 72.0 Once upon a time in Holywood
- 71.0 Downton Abbey
- 70.0 The Man with the Golden Gun
- 69.0 The King’s Choice
- 68.0 The Marvelous Mrs. Maisel
- 67.0 A Beautiful Mind
- 66.0 Les Misérables
- 65.0 Back to the Future
- 64.0 The man who would be king
- 63.0 Greed in the Sun
- 62.0 Farewell
- 61.0 Seven Pounds
- 60.0 Better Call Saul
- 59.0 The Lobster
- 58.0 Journey to the Christmas Star
- 57.0 Star Trek: Discovery
- 56.0 The Second Mother
- 55.0 Never Let Me Go
- 54.1 House of Cards (minor release)
- 54.0 House of Cards
- 53.0 Rear Window
- 52.0 Pat & Mat
- 51.0 The White Mountains
- 50.0 A Dog’s Will
- 49.0 The Physician
- 48.0 Lost Boundaries
- 47.0 The Lost Wife
- 46.0 Burning Bush
- 45.0 Anthropoid
- 44.0 The Shadow Self
- 43.0 The Emperor and the Golem
- 42.0 Stranger Things
- 41.0 Outlander
- 40.0 Dr Who
- 39.0 The Hateful Eight
- 38.0 Love, Ken
- 37.0 Trabant vs. South America
- 36.0 LTS
- 35.0 Mr. Robot
- 0.34.0 The Hour of the Star
- 0.33.0 Lemonade Joe or Horse Opera
- 0.32.0 Road Runner
- 0.31.0 Lucky Luke
- 0.30.0 Jimmy’s Hall
- 0.29.0 Steven Universe
- 0.28.0 Jára Cimrman, The Investigation of the Missing Class Register
- 0.27.1
- 0.27.0 Terminator: Genisys
- 0.26.0 The Office
- 0.25.0 Blade
Future/Experimental
Blueprints
Learn More
Test API¶
API Reference
- Test APIs
- Internal (Core) APIs
- Submodules
- avocado.core.app module
- avocado.core.data_dir module
- avocado.core.decorators module
- avocado.core.defaults module
- avocado.core.dispatcher module
- avocado.core.enabled_extension_manager module
- avocado.core.exceptions module
- avocado.core.exit_codes module
- avocado.core.extension_manager module
- avocado.core.job module
- avocado.core.job_id module
- avocado.core.jobdata module
- avocado.core.loader module
- avocado.core.nrunner module
- avocado.core.nrunner_avocado_instrumented module
- avocado.core.output module
- avocado.core.parameters module
- avocado.core.parser module
- avocado.core.parser_common_args module
- avocado.core.plugin_interfaces module
- avocado.core.references module
- avocado.core.resolver module
- avocado.core.result module
- avocado.core.runner module
- avocado.core.safeloader module
- avocado.core.settings module
- avocado.core.settings_dispatcher module
- avocado.core.status module
- avocado.core.sysinfo module
- avocado.core.tags module
- avocado.core.tapparser module
- avocado.core.test module
- avocado.core.tree module
- avocado.core.varianter module
- avocado.core.version module
- Module contents
- Utilities APIs
- Subpackages
- Submodules
- avocado.utils.archive module
- avocado.utils.asset module
- avocado.utils.astring module
- avocado.utils.aurl module
- avocado.utils.build module
- avocado.utils.cloudinit module
- avocado.utils.configure_network module
- avocado.utils.cpu module
- avocado.utils.crypto module
- avocado.utils.data_factory module
- avocado.utils.data_structures module
- avocado.utils.datadrainer module
- avocado.utils.debug module
- avocado.utils.diff_validator module
- avocado.utils.disk module
- avocado.utils.distro module
- avocado.utils.download module
- avocado.utils.file_utils module
- avocado.utils.filelock module
- avocado.utils.gdb module
- avocado.utils.genio module
- avocado.utils.git module
- avocado.utils.iso9660 module
- avocado.utils.kernel module
- avocado.utils.linux module
- avocado.utils.linux_modules module
- avocado.utils.lv_utils module
- avocado.utils.memory module
- avocado.utils.multipath module
- avocado.utils.network module
- avocado.utils.output module
- avocado.utils.partition module
- avocado.utils.path module
- avocado.utils.pci module
- avocado.utils.process module
- avocado.utils.script module
- avocado.utils.service module
- avocado.utils.software_manager module
- avocado.utils.ssh module
- avocado.utils.stacktrace module
- avocado.utils.vmimage module
- avocado.utils.wait module
- Module contents
- Extension (plugin) APIs
- Submodules
- avocado.plugins.archive module
- avocado.plugins.assets module
- avocado.plugins.config module
- avocado.plugins.diff module
- avocado.plugins.distro module
- avocado.plugins.envkeep module
- avocado.plugins.exec_path module
- avocado.plugins.expected_files_merge module
- avocado.plugins.human module
- avocado.plugins.jobscripts module
- avocado.plugins.journal module
- avocado.plugins.json_variants module
- avocado.plugins.jsonresult module
- avocado.plugins.list module
- avocado.plugins.multiplex module
- avocado.plugins.nlist module
- avocado.plugins.nrun module
- avocado.plugins.plugins module
- avocado.plugins.replay module
- avocado.plugins.resolvers module
- avocado.plugins.run module
- avocado.plugins.runnable_run module
- avocado.plugins.runnable_run_recipe module
- avocado.plugins.runner module
- avocado.plugins.runner_nrunner module
- avocado.plugins.sysinfo module
- avocado.plugins.tap module
- avocado.plugins.task_run module
- avocado.plugins.task_run_recipe module
- avocado.plugins.teststmpdir module
- avocado.plugins.variants module
- avocado.plugins.vmimage module
- avocado.plugins.wrapper module
- avocado.plugins.xunit module
- Module contents
- Optional Plugins API
- avocado_loader_yaml package
- avocado_result_upload package
- avocado_runner_remote package
- avocado_robot package
- avocado_runner_docker package
- avocado_varianter_yaml_to_mux package
- avocado_glib package
- avocado_golang package
- avocado_varianter_pict package
- avocado_varianter_cit package
- avocado_resultsdb package