slackapi / bolt-python

A framework to build Slack apps using Python
https://slack.dev/bolt-python/
MIT License
1.04k stars 238 forks source link

chore: improve unit test speed #1109

Closed WilliamBergamin closed 1 month ago

WilliamBergamin commented 1 month ago

This PR is a follow up to #1017, it aim to speed up unit test execution

Many unit tests use asyncio.sleep before asserting that a request to mock_web_api_server was successfully processed. These changes allow unit tests to continue as soon as requests to mock_web_api_server are processed, instead of waiting an arbitrary amount of time.

This reuses the same logic introduced by #1017 and applies it to the async area of the unit tests.

Original

Screenshot 2024-07-11 at 12 53 04 PM

Before this PR

Screenshot 2024-07-11 at 12 53 36 PM

After

Screenshot 2024-07-11 at 12 53 57 PM

Take away

In GitHub actions using python 3.11, this PR allows the unit tests to run in 2m18s this is a 38% improvement compared to 3m45s previously and a 54% improvement compare to executions pre #1017

On my local machine using python 3.11, this PR allows the unit tests to run in 1m35s this is a 43% improvement compared to 2m49s previously

Category (place an x in each of the [ ])

Requirements (place an x in each [ ])

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 91.80%. Comparing base (7b19d3d) to head (c323fdc).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1109 +/- ## ========================================== + Coverage 91.79% 91.80% +0.01% ========================================== Files 186 186 Lines 6408 6408 ========================================== + Hits 5882 5883 +1 + Misses 526 525 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.