Closed WaterLoran closed 3 weeks ago
That's unittest
logic. (Not from SeleniumBase, which inherits unittest
logic.)
If the setUp()
method fails, nothing else runs:
from unittest import TestCase
class MyTestClass(TestCase):
def setUp(self):
super().setUp()
print("SetUp")
assert False
def test_base(self):
print("TheTest")
def tearDown(self):
print("TearDown")
super().tearDown()
If you want to make sure things get run, wrap unreliable code in a try
/except
block:
from unittest import TestCase
class MyTestClass(TestCase):
def setUp(self):
super().setUp()
print("SetUp")
try:
assert False
except Exception:
pass
def test_base(self):
print("TheTest")
def tearDown(self):
print("TearDown")
super().tearDown()
The same holds true with SeleniumBase
:
examples/boilerplates/base_test_case.py
Thank you very much. Originally, it was due to directly inheriting the Unittest engine, which is different from the execution logic of Pytest. Therefore, I have this question. Thank you very much
The corresponding test script is:
coding: utf-8
from seleniumbase import BaseCase
class TestCheckAndJumpOnOpenOrganizationCode001(BaseCase):
########################## Actual process information:![image](https://github.com/seleniumbase/SeleniumBase/assets/52927459/5db57d22-12d0-4e5c-99d3-ccaabd68f16e)
############################# My expectations: It is expected that when the script fails to execute in the setup, the tearDown function can also be executed, which should be consistent with the execution logic of pytest