google / mobly

E2E test framework for tests with complex environment requirements.
https://github.com/google/mobly
Apache License 2.0
634 stars 177 forks source link

Why don't BaseTestCase inherit from built-in unittest? #675

Closed williamfzc closed 4 years ago

williamfzc commented 4 years ago

Hi

https://github.com/google/mobly/blob/6f867938373e096ac5207b04b42699fb0935a519/mobly/base_test.py#L52

Just a little curious about why mobly implemented a new independent test class module? Using built-in unittest instead looks more extendable

xpconanfan commented 4 years ago

Because the unittest base class was designed for unit tests, whereas Mobly tests are e2e tests that are more complex. E.g. features like on_fail, multi-error reporting mechanism, and separate assertion module do not exist in unittest.

williamfzc commented 4 years ago

Thanks I see.

williamfzc commented 4 years ago

oh, another question:

Mobly was designed as a complete test framework not a package. So using without TestClass is not encouraged (I guess because all the examples working inside TestClass), and some important methods are also built-in members of TestClass, like register_controller.

Mobly offered lots of powerful API. Is there an official way to use them without TestClass?

xpconanfan commented 4 years ago

Mobly is designed to be modular, so the controller modules can be directly imported and used as libraries without Mobly's base class. But if your purpose is to write test cases, I'd still suggest using Mobly's base class over unittest. Because unittest simply couldn't handle the complexity inherent to e2e tests.