0

I want to run particular test cases for the first time. When we run the test cases file, my particular test cases need to be executed first.

I wrote test cases in python by using the unit-test module.

class TestEx(unittest.TestCase):
    def setUp(self):
        pass
    def test_numbers(self):
        self.assertEqual(3*4, 12)
    def test_strings(self):
        self.assertEqual('a'*3, 'aaa')
    def test_my(self):
        self.assertTrue('in' in 'inspect')


if __name__ == '__main__':
    unittest.main()

When I run the code it's executed like

test_my (__main__.TestEX) ... ok
test_numbers (__main__.TestEx) ... ok
test_strings (__main__.TestEx) ... ok

But I want to run test_numbers test case first. Is it possible?

Anusha Konduru
  • 111
  • 2
  • 3
  • 11
  • Possible duplicate - see discussion here - https://stackoverflow.com/questions/4095319/unittest-tests-order – Tom Ron Jul 26 '18 at 06:18
  • Possible duplicate of [Running unittest with typical test directory structure](https://stackoverflow.com/questions/1896918/running-unittest-with-typical-test-directory-structure) – Gautham Srinivasan Jul 26 '18 at 06:39
  • Don't write tests so their order matters. That is very bad practice. Write tests so they are independent. –  Jul 26 '18 at 07:32
  • Possible duplicate of [Python unittest.TestCase execution order](https://stackoverflow.com/questions/5387299/python-unittest-testcase-execution-order) –  Jul 26 '18 at 07:44

0 Answers0