[Avocado-devel] Test assumptions question.

Cleber Rosa crosa at redhat.com
Wed Sep 14 14:44:58 UTC 2016



On 09/14/2016 09:57 AM, Dmitry Monakhov wrote:
> Fam Zheng <famz at redhat.com> writes:
> 
>> On Wed, 09/14 10:51, Dmitry Monakhov wrote:
>>> class AvocadoRelease(Test):
>>>
>>>     def setUp(self):
>>>         self.log.info("do setUp: install requirements, fetch source")
>>>
>>>     def test_a(self):
>>>         self.log.info("do test_a: inspekt lint")
>>>
>>>     def test_b(self):
>>> 	self.log.info("do test_b: inspekt style")
>>>
>>>     def tearDown(self):
>>>         self.log.info("do tearDown")
>>> My assumptions was that test sequence will be:
>>> do setUp
>>> do test_a: inspekt lint
>>> do test_b: inspekt style
>>> do tearDown
>>> But it is appeared that each testcase is wrapped with setUp()/teerDown()
>>> ####
>>> START 1-simpletest.py:AvocadoReliase.test_a
>>> do setUp: install requirements, fetch source
>>> do test_a: inspekt lint
>>> do tearDown
>>> PASS 1-simpletest.py:AvocadoReliase.test_a
>>> START 2-simpletest.py:AvocadoReliase.test_b
>>> do setUp: install requirements, fetch source
>>> do test_b: inspekt style
>>> do tearDown
>>> PASS 2-simpletest.py:AvocadoReliase.test_b
>>> ####
>>> This is not obvious. And makes it hard to divide test to
>>> fine-grained testcases because setUp/teerDown() for each test may
>>> be too intrusive. What is convenient way implement this scenario?
>>
>> This is the interface of Python's unittest.TestCase (base class of avocado Test
>> class).  It also offers setUpClass and tearDownClass that do what you want
>> above.
>>
>> See also `pydoc unittest.TestCase`.
> Indeed. But avocado.Test() does not call setUpClass/tearDownClass.
> it call only setUp/tearDown. AIFAU this is done that way because
> each test is executed in supbrocess. See runner.py:TestRunner.run_test:
>     proc = multiprocessing.Process(target=self._run_test,
>                                        args=(test_factory, queue,))
> 

Right, that's the exact reason.  It was also better discussed/explained
here:

https://github.com/avocado-framework/avocado/issues/1148#issuecomment-245686047

Which makes me think that we should officially document that:

https://trello.com/c/bN7w5Vzh/826-unittest-compatibility-document-process-model-and-class-setup-teardown-support

> IMHO this is a bit unusual, but cool because allow to support
> concurrent test execution in future.
> IMHO It would be nice document it somewhere, for example add compat mode where:
> setUpClass/tearDownClass are called similar to setUp/tearDown, but
> dump warning in a log.
> 
> BTW: Are any chance to implement parallel executions in near future ?
> https://trello.com/c/xNeR2slj/255-support-running-tests-in-parallel

We have had this in mind for a while, but other features have been
considered higher priority.  Discussing it and sending prototypes is a
good way to get this running.

Thanks!

>> Fam

-- 
Cleber Rosa
[ Sr Software Engineer - Virtualization Team - Red Hat ]
[ Avocado Test Framework - avocado-framework.github.io ]

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/avocado-devel/attachments/20160914/94a5fa85/attachment.sig>


More information about the Avocado-devel mailing list