craigahobbs / unittest-parallel

Parallel unit test runner for Python with coverage support
MIT License
29 stars 5 forks source link

How do i get this to work? #1

Closed jsuhhome closed 4 years ago

jsuhhome commented 5 years ago

tried unittest-parallel -j 3

with

 class TestA(unittest.TestCase):
   def setUp(self):
    pass

def test_A(self):
    for i in range(10):
        print('A' + str(i) + ': ' + str(datetime.datetime.now()))
        time.sleep(1)

def test_B(self):
    for i in range(10):
        print('B' + str(i) + ': ' + str(datetime.datetime.now()))
        time.sleep(1)

def test_C(self):
    for i in range(10):
        print('C' + str(i) + ': ' + str(datetime.datetime.now()))
        time.sleep(1)

def tearDown(self):
    pass

if name == 'main': unittest.main()

but it went sequentially

craigahobbs commented 5 years ago

unittest-parallel parallelizes at the test suite level (your class definition). To get your tests to run in parallel above you'd need to put them each in their own class. IMO unittest-parallel is best used for projects with 100's or 1000's of unit tests. For anything less I'd recommend using the built-in python unit test runner (python -m unittest).

Craig

On Wed, Jun 19, 2019 at 3:56 PM jsuhhome notifications@github.com wrote:

tried unittest-parallel -j 3

with ` import unittest import datetime import time

class TestA(unittest.TestCase):

def setUp(self): pass

def test_A(self): for i in range(10): print('A' + str(i) + ': ' + str(datetime.datetime.now())) time.sleep(1)

def test_B(self): for i in range(10): print('B' + str(i) + ': ' + str(datetime.datetime.now())) time.sleep(1)

def test_C(self): for i in range(10): print('C' + str(i) + ': ' + str(datetime.datetime.now())) time.sleep(1)

def tearDown(self): pass

if name == 'main': unittest.main() `

but it went sequentially

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/craigahobbs/unittest-parallel/issues/1?email_source=notifications&email_token=AAJUPG7UADLQBSHLQV4JYCLP3K2RVA5CNFSM4HZN6ZI2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G2QQH3Q, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJUPG5MG3Y6V77RM3FOX2LP3K2RVANCNFSM4HZN6ZIQ .