[Avocado-devel] [RFC] Recursive Test Discovery [V2]
Lukáš Doktor
ldoktor at redhat.com
Mon Jun 5 12:59:49 UTC 2017
Dne 2.6.2017 v 09:26 Amador Pahim napsal(a):
> Motivation
> ==========
>
> Currently we can discover test classes that does not inherit directly
> from `avocado.Test`. To do so, we rely on the inclusion of a docstring
> (`:avocado: enable`) in the mentioned class. Example below.
>
> File `/usr/share/avocado/tests/test_base_class.py`::
>
> from avocado import Test
>
>
> class BaseClass(Test):
>
> def test_basic(self):
> pass
>
> File `/usr/share/avocado/tests/test_first_child.py`::
>
> from test_base_class import BaseClass
>
>
> class FirstChild(BaseClass):
> """
> :avocado: enable
> """
>
> def test_first_child(self):
> pass
>
> In the example above, if we ask Avocado to list the tests from
> `test_first_child.py`, `FirstChild.test_first_child` will be listed and
> the `BaseClass.test_basic` won't::
>
> $ avocado list test_first_child.py
> INSTRUMENTED test_first_child.py:FirstChild.test_first_child
>
> The request is that, in such cases, we have a way to include the
> `BaseClass.test_basic` into the results.
>
> Proposal
> ========
>
> To include the parent classes into the discovery results, we have three
> main aspects to consider:
>
> - How to flag that we want that behaviour?
> The proposal is the creation of a new docstring `recursive`. Example::
>
> class FirstChild(BaseClass):
> """
> :avocado: recursive
> """
> ...
>
> - How deep is the recursion?
> The proposal is that the recursion goes all the way up to the class
> inheriting from `avocado.Test`.
Do you really want to break the recursion there? I'd simply go to the
end of inheritance (therefor `object`).
Although I'd mention it will combine the full inheritance (including
multiple parents) always till the `object` (as some of them may not be
inherited from `avocado.Test`).
Therefor I'd simply say: The proposal is to go through the full
inheritance list recursively creating a set of `test*` methods
simulating the dynamic loader (except of dynamic methods created during
__init__).
>
> - Will the recursion respect the parents docstrings?
> The proposal is that the docstrings in the parents are ignored when
> recursively discovering. Example:
>
> File `/usr/share/avocado/tests/test_base_class.py`::
>
> from avocado import Test
>
>
> class BaseClass(Test):
> """
> :avocado: disable
> """
>
> def test_basic(self):
> pass
>
> File `/usr/share/avocado/tests/test_first_child.py`::
>
> from test_base_class import BaseClass
>
>
> class FirstChild(BaseClass):
> """
> :avocado: recursive
> """
>
> def test_first_child(self):
> pass
>
> Will result in::
>
> $ avocado list test_first_child.py
> INSTRUMENTED test_first_child.py:FirstChild.test_first_child
> INSTRUMENTED test_first_child.py:BaseClass.test_basic
>
>
> Expected Results
> ================
>
> The expected result is to provide users more flexibility when creating
> the Avocado tests, being ablr to create a chain of test classes and
able
> providing only the module containing the last one as a test reference.
>
> Additional Information
> ======================
>
> Avocado uses only static analysis to examine the files and this
> feature should stick to this principle in its implementation.
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 502 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/avocado-devel/attachments/20170605/91ef858c/attachment.sig>
More information about the Avocado-devel
mailing list