Last active
May 27, 2021 02:52
-
-
Save eric100lin/d6592a5d00e1053a2ab3b2e1636d49c6 to your computer and use it in GitHub Desktop.
Have fun with PR/734: https://github.com/google/mobly/pull/734 and PR/751: https://github.com/google/mobly/pull/751
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mobly import base_test | |
from mobly import signals | |
from mobly import test_runner | |
from mobly.controllers import android_device | |
class HelloWorldTest(base_test.BaseTestClass): | |
def setup_class(self): | |
# Registering android_device controller module declares the test's | |
# dependency on Android device hardware. By default, we expect at least one | |
# object is created from this. | |
self.dut = self.register_controller(android_device)[0] | |
# Start Mobly Bundled Snippets (MBS). | |
self.dut.load_snippet('mbs', 'com.google.android.mobly.snippet.bundled') | |
self.count = 0 | |
@base_test.retry(3) | |
def test_hello(self): | |
self.dut.log.info('This run is %s', self.current_test_info.name) | |
self.dut.log.info('The record is %s', self.current_test_info.record) | |
self.dut.mbs.makeToast('Hello World!') | |
self.record_data( | |
{f'dummy_key_{self.count}': str(self.current_test_info.record)}) | |
if self.count != 2: | |
self.count += 1 | |
raise signals.TestFailure(f'Fake failure for round {self.count}!!') | |
if __name__ == '__main__': | |
test_runner.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
05-27 10:38:17.622 INFO Test output folder: "/tmp/logs/mobly/SampleTestBed/05-27-2021_10-38-17-622" | |
05-27 10:38:17.623 INFO ==========> HelloWorldTest <========== | |
05-27 10:38:26.054 INFO [AndroidDevice|04171FQCB00869] Launching snippet apk com.google.android.mobly.snippet.bundled with protocol 1.0 | |
05-27 10:38:26.463 INFO [Test] test_hello | |
05-27 10:38:26.463 INFO [AndroidDevice|04171FQCB00869] This run is test_hello | |
05-27 10:38:26.463 INFO [AndroidDevice|04171FQCB00869] The record is Test Name = test_hello, Test Class = HelloWorldTest, Begin Time = 1622083106464, End Time = None, Result = None, UID = None, Signature = test_hello-1622083106464, Retry Parent = None, Extras = None, Details = None, Extra Errors = {}, Stacktrace = None | |
05-27 10:38:26.482 ERROR Exception occurred in test_hello. | |
Traceback (most recent call last): | |
File "/mnt/sda/mobly/mobly/base_test.py", line 756, in exec_one_test | |
test_method() | |
File "/mnt/sda/mobly/mobly/base_test.py", line 129, in _wrapper | |
func(*args) | |
File "/usr/local/google/home/ericth/IdeaProjects/Scratch/hello_world_test.py", line 33, in test_hello | |
raise Exception(f'Fake failure for round {self.count}!!') | |
Exception: Fake failure for round 1!! | |
05-27 10:38:26.484 INFO [Test] test_hello ERROR | |
05-27 10:38:26.488 INFO [Test] test_hello_retry_1 | |
05-27 10:38:26.488 INFO [AndroidDevice|04171FQCB00869] This run is test_hello_retry_1 | |
05-27 10:38:26.488 INFO [AndroidDevice|04171FQCB00869] The record is Test Name = test_hello_retry_1, Test Class = HelloWorldTest, Begin Time = 1622083106488, End Time = None, Result = None, UID = None, Signature = test_hello_retry_1-1622083106488, Retry Parent = test_hello-1622083106464, Extras = None, Details = None, Extra Errors = {}, Stacktrace = None | |
05-27 10:38:26.512 ERROR Exception occurred in test_hello_retry_1. | |
Traceback (most recent call last): | |
File "/mnt/sda/mobly/mobly/base_test.py", line 756, in exec_one_test | |
test_method() | |
File "/mnt/sda/mobly/mobly/base_test.py", line 129, in _wrapper | |
func(*args) | |
File "/usr/local/google/home/ericth/IdeaProjects/Scratch/hello_world_test.py", line 33, in test_hello | |
raise Exception(f'Fake failure for round {self.count}!!') | |
Exception: Fake failure for round 2!! | |
05-27 10:38:26.513 INFO [Test] test_hello_retry_1 ERROR | |
05-27 10:38:26.516 INFO [Test] test_hello_retry_2 | |
05-27 10:38:26.517 INFO [AndroidDevice|04171FQCB00869] This run is test_hello_retry_2 | |
05-27 10:38:26.517 INFO [AndroidDevice|04171FQCB00869] The record is Test Name = test_hello_retry_2, Test Class = HelloWorldTest, Begin Time = 1622083106517, End Time = None, Result = None, UID = None, Signature = test_hello_retry_2-1622083106517, Retry Parent = test_hello_retry_1-1622083106488, Extras = None, Details = None, Extra Errors = {}, Stacktrace = None | |
05-27 10:38:26.603 ERROR Exception occurred in test_hello_retry_2. | |
Traceback (most recent call last): | |
File "/mnt/sda/mobly/mobly/base_test.py", line 756, in exec_one_test | |
test_method() | |
File "/mnt/sda/mobly/mobly/base_test.py", line 129, in _wrapper | |
func(*args) | |
File "/usr/local/google/home/ericth/IdeaProjects/Scratch/hello_world_test.py", line 33, in test_hello | |
raise Exception(f'Fake failure for round {self.count}!!') | |
Exception: Fake failure for round 3!! | |
05-27 10:38:26.604 INFO [Test] test_hello_retry_2 ERROR | |
05-27 10:38:26.607 INFO [Test] test_ok | |
05-27 10:38:26.607 INFO [AndroidDevice|04171FQCB00869] This run is test_ok | |
05-27 10:38:26.608 INFO [AndroidDevice|04171FQCB00869] The record is Test Name = test_ok, Test Class = HelloWorldTest, Begin Time = 1622083106608, End Time = None, Result = None, UID = None, Signature = test_ok-1622083106608, Retry Parent = None, Extras = None, Details = None, Extra Errors = {}, Stacktrace = None | |
05-27 10:38:26.628 INFO [Test] test_ok PASS | |
05-27 10:38:27.768 INFO Summary for test class HelloWorldTest: Error 3, Executed 4, Failed 0, Passed 1, Requested 2, Skipped 0 | |
05-27 10:38:27.768 INFO Summary for test run SampleTestBed@05-27-2021_10-38-17-622: | |
Total time elapsed 10.145916291046888s | |
Artifacts are saved in "/tmp/logs/mobly/SampleTestBed/05-27-2021_10-38-17-622" | |
Test results: Error 3, Executed 4, Failed 0, Passed 1, Requested 2, Skipped 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
Requested Tests: | |
- test_hello | |
Type: TestNameList | |
--- | |
Type: UserData | |
dummy_key_0: Test Name = test_hello, Test Class = HelloWorldTest, Begin Time = 1618999395168, | |
End Time = None, Result = None, UID = None, Extras = None, Details = None, Extra | |
Errors = {}, Stacktrace = None | |
timestamp: 1618999395208 | |
--- | |
Begin Time: 1618999395168 | |
Details: Fake failure for round 1!! | |
End Time: 1618999395211 | |
Extra Errors: {} | |
Extras: null | |
Result: FAIL | |
Stacktrace: "Traceback (most recent call last):\n File \"/mnt/sda/mobly/mobly/base_test.py\"\ | |
, line 704, in exec_one_test\n test_method()\n File \"/mnt/sda/mobly/mobly/base_test.py\"\ | |
, line 119, in _wrapper\n func(*args)\n File \"/usr/local/google/home/ericth/IdeaProjects/Scratch/hello_world_test.py\"\ | |
, line 27, in test_hello\n raise signals.TestFailure(f'Fake failure for round\ | |
\ {self.count}!!')\nmobly.signals.TestFailure: Details=Fake failure for round\ | |
\ 1!!, Extras=None\n" | |
Test Class: HelloWorldTest | |
Test Name: test_hello | |
Type: Record | |
UID: null | |
--- | |
Type: UserData | |
dummy_key_1: Test Name = test_hello_retry_1, Test Class = HelloWorldTest, Begin Time | |
= 1618999395215, End Time = None, Result = None, UID = None, Extras = None, Details | |
= None, Extra Errors = {}, Stacktrace = None | |
timestamp: 1618999395258 | |
--- | |
Begin Time: 1618999395215 | |
Details: Fake failure for round 2!! | |
End Time: 1618999395260 | |
Extra Errors: {} | |
Extras: null | |
Result: FAIL | |
Stacktrace: "Traceback (most recent call last):\n File \"/mnt/sda/mobly/mobly/base_test.py\"\ | |
, line 704, in exec_one_test\n test_method()\n File \"/mnt/sda/mobly/mobly/base_test.py\"\ | |
, line 119, in _wrapper\n func(*args)\n File \"/usr/local/google/home/ericth/IdeaProjects/Scratch/hello_world_test.py\"\ | |
, line 27, in test_hello\n raise signals.TestFailure(f'Fake failure for round\ | |
\ {self.count}!!')\nmobly.signals.TestFailure: Details=Fake failure for round\ | |
\ 2!!, Extras=None\n" | |
Test Class: HelloWorldTest | |
Test Name: test_hello_retry_1 | |
Type: Record | |
UID: null | |
--- | |
Type: UserData | |
dummy_key_2: Test Name = test_hello_retry_2, Test Class = HelloWorldTest, Begin Time | |
= 1618999395263, End Time = None, Result = None, UID = None, Extras = None, Details | |
= None, Extra Errors = {}, Stacktrace = None | |
timestamp: 1618999395377 | |
--- | |
Begin Time: 1618999395263 | |
Details: null | |
End Time: 1618999395379 | |
Extra Errors: {} | |
Extras: null | |
Result: PASS | |
Stacktrace: null | |
Test Class: HelloWorldTest | |
Test Name: test_hello_retry_2 | |
Type: Record | |
UID: null | |
--- | |
Controller Info: | |
- build_info: | |
build_characteristics: nosdcard | |
build_id: RQ3A.210605.001 | |
build_product: sunfish | |
build_type: userdebug | |
build_version_codename: REL | |
build_version_sdk: '30' | |
debuggable: '1' | |
hardware: sunfish | |
product_name: sunfish | |
model: sunfish | |
serial: 9C041FQC200408 | |
user_added_info: {} | |
Controller Name: AndroidDevice | |
Test Class: HelloWorldTest | |
Timestamp: 1618999395.4057362 | |
Type: ControllerInfo | |
--- | |
Error: 0 | |
Executed: 3 | |
Failed: 2 | |
Passed: 1 | |
Requested: 1 | |
Skipped: 0 | |
Type: Summary |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment