0

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.

Viterzgir
  • 212
  • 4
  • 14
  • For functional UI tests, it's easier to play with robotframework + selenium. You shouls arrange unit tests with proper setups / teardowns such the test execution order does not matter. When fixing / adding a feature, you would like to run only specific tests and not the whole suite. – glenfant Aug 23 '17 at 14:35
  • @glenfant, yes, I know about that framework but I found it a little bit complicated. I use Selene instead + webdriver manager. – Viterzgir Aug 23 '17 at 15:37

0 Answers0