jerry-git / pytest-split

Pytest plugin which splits the test suite to equally sized "sub suites" based on test execution time.
https://jerry-git.github.io/pytest-split/
MIT License
246 stars 30 forks source link

Possibility to split tests on Class basis #82

Open adaptivecodes opened 1 year ago

adaptivecodes commented 1 year ago

I am currently using this plugin for splitting up my tests. A lot of my pytests consist of multiple test cases which are depended on one another. Is there a possibility to split the tests on class basis? Example: Testclass A: test_01: test_02: Testclass B: test_01: test_02: test_03: Testclass C: test_01: Splitting those in two would do something like this: Batch A: A(test_01, test_02) C(test_01) Batch B: B (test_01, test_02, test_03)

Currently I am getting something like this: Batch A: A(test_01, test_02) B(test_01) Batch B: B(test_02, test_03), C(test_01)

Maybe I am missing something. If this is not possible at the moment are you willing to accept a Pull Request?

Greetings, Andreas

christianbundy commented 7 months ago

Adding my use-case here: Django's TestCase runs one transaction per class, so it's optimal to run each class on a single worker.

jerry-git commented 4 months ago

Happy to take a PR for this 🙂 I this the best would be to have a CLI flag for it such that it could be used with all the current (and future) splitting algorithms. Another option would be to implement a new splitting algorithm which is tailored for this class use case.