I came to Python from Java world. I found these TestNG-like tools: py.test
, nose2
and unittest
. Played a little with all of them but I found some simple examples with unittest
so I decided to stick to it.
I automate only website's UI part for now with API automation on the horizon.
Does unittest
runs added Test Cases
in order I added those classes? If not how can I order them?
Here's what I found:
import unittest
from SeleniumPythonRefactorTestCase import SearchText
from SeleniumPythonMultipleTests import HomePageTest
# get all tests from SearchText and HomePageTest class
search_text = unittest.TestLoader().loadTestsFromTestCase(SearchText)
home_page_test = unittest.TestLoader().loadTestsFromTestCase(HomePageTest)
# create a test suite combining search_text and home_page_test
test_suite = unittest.TestSuite([home_page_test, search_text])
# run the suite
unittest.TextTestRunner(verbosity=2).run(test_suite)
I have lots of different classes which consist some parts of logic so I can create different Test Suites
using the same Test Case
classes.
BTW, is unittest
good for this job? Basically, I need this only for creating Test Case
and Test Suites
.
Thanks.