i am trying to my following :

from Login_Page import LoginPageAndLogout

def test_suite():
    # get all tests from classes
    login_test = .TestLoader().loadTestsFromTestCase(LoginPageAndLogout)

    # create a test suite
    all_tests = .TestSuite([

    # run the suite

from Pycharm’s using the command :

sudo  selenium-tests/testSuite.py -vvv -s

and a part of the output is the following:

============================================================================================================ test session starts ============================================================================================================
platform linux2 -- Python 2.7.14, pytest-3.1.3, py-1.4.34, pluggy-0.4.0 -- /usr/bin/python
cachedir: .cache
rootdir: /home/osboxes/PycharmProjects/WebTesting, inifile:
plugins: cov-2.5.1
collected 3 items 

selenium-tests/testSuite.py::LoginPageAndLogout::test_failed_login <- selenium-tests/Login_Page.py PASSED
selenium-tests/testSuite.py::LoginPageAndLogout::test_login <- selenium-tests/Login_Page.py FAILED
selenium-tests/testSuite.py::test_suite test_failed_login (Login_Page.LoginPageAndLogout) ... ok
test_login (Login_Page.LoginPageAndLogout) ... ok

Ran 2 tests in 55.993s

The structure of my Login_Page.py file is:

class LoginPageAndLogout(unittest.TestCase):

    def setUp(self):
        # ...

    # login with incorrect credentials to get error message
    def test_failed_login(self):
        # ...

    # login with correct credentials
    def test_login(self):
        # ...

    def tearDown(self):
        # ...

As you can see from the output, I have 2 tests but the terminal collects three things instead and run each test twice. Is there a way to execute only the PASSED/FAILED execution, not the ... ok ?

If I comment out unittest.TextTestRunner(verbosity=2).run(all_tests) my tests executed only once but I get the ... ok result instead of the PASSED/FAILED which is the one I want; so I see the pytest execution instead of the unittests .

How can I run from the terminal my suite using the unitest runner only?

Source link https://sqa.stackexchange.com/questions/35409/-test-suite-from-both-terminal-using-pytest-and-unittest-runner-but-


Please enter your comment!
Please enter your name here