-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test #904
Add test #904
Conversation
Yes, unit testing is currently urgently needed by Workman. Thank you very much for your contribution. |
Yes, we need tests. And I really like to use Pest. But we don't need too many unit tests, only for some classes. We need more URGENT to have functional tests.It's better to test the behavior than the code in Workerman. Apache and Nginx use functional testsApache: Nginx: Also Ngx-php use the functional test from Nginx: https://github.com/rryqszq4/ngx-php/blob/master/t/001-hello.t Both use perl, because are veterans projects, and at that time is what they have at hand. PHP use functional testsA better example, is the same PHP.
We need an slight modified .phpt tests. And try to be language agnostic. And I think more in have an echo server in some parts, like in https://httpbin.org Other optionsWe can start fast and use ready made solutions, but they have disadvantages too. Thunder Client Negative:
Rest client Easy to create, and with autocomplete in IDEs of .rest and .http files (both have RFCs) Very good way, perhaps better than .phpt for Workeman. Also separated in dirs and easy to review changes in commits. Negative:
What is better to use? Link to issue #833 |
I copied the comment to the issue, so will be better to continue the conversation. |
f24d86f
to
098c8b6
Compare
Yes and no. The unit tests I wrote are against
While I still believe unit tests are necessary and important, I also agree behavior tests are equally needed. I tried to add one for general udp connection which turns out not feasible at this moment, as pest doesn't support process isolation while the only way to stop/kill workerman workers is killing the whole process. ← Please correct me if I'm wrong. I'll mark this PR as ready for review, as the key point of this PR is to introduce testing tools with CI. I can remove all test cases or move them to another PR if necessary. The author of pest doesn't seem to have interest to add process isolation although he is open to a PR. There was one but abandoned. I think I will spend some time to look into that, or if any solution on workerman side is also helpful. |
Yes, both unit testing and behavioral testing are required. Thank you for jhdxr's PR and joanhey's detailed discussion. I have merged the PR on unit testing. I am not familiar with testing but using Perl may not seem like a good idea, as most developers are not familiar with it now. Perhaps we can also use PHPUnit for behavioral testing? |
The .phpt in php use PHP. |
Yes, .phpt is ok. |
|
TL;DR
This PR adds Github Action enabled tests with coverage.
This PR adds:
Pest
for testing andmockery
for mock as dev dependency.master
branch and PR.Currently there is only one completed test case for demonstration purpose. I may add more if maintainers are interested in this PR.