-
Notifications
You must be signed in to change notification settings - Fork 575
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
Setup testing environment and configure tools #419
Conversation
I would like to throw in https://pptr.dev/ which we have made better experience with. It's not using selenium and because of this much more stable. It's also a lot faster and because it's testing frontend the tests could be written by a frontendler via https://mochajs.org/ and https://www.chaijs.com/ without the need to know php & phpunit. Or if you don't need browser interaction I can recommend https://github.com/spatie/phpunit-snapshot-assertions to simply compare responded HTML. |
<env name="SESSION_DRIVER" value="array"/> | ||
<env name="QUEUE_DRIVER" value="sync"/> | ||
<env name="MAIL_DRIVER" value="array"/> | ||
<env name="DB_CONNECTION" value="sqlite"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use testing
to use :memory:
by default. Or was this connection introduced after Laravel 5.3? :/
PS: the super low/old min Laravel version makes things very difficult.
@Gummibeer, you would use Puppeteer to test what exactly? Snapshot assertions are nice if we can integrate them to a testing tool like Testbench, because for backend integration testing in Laravel apps/packages it is still the best one. For browser testing I would try to stick to Laravel Dusk, actually Testbench-dusk, it uses Chromedriver too and is deeply integrated to the Laravel ecosystem, making it very easy to interact with fronted and check if data sent to backend is being rendered as it should, for example. What I think we might really go non-laravel is if we start writing tests for VueJS components in isolation, it wouldn’t make sense test them using PHP, if we are not testing integration between them and the backend. But, look, this is only a starting point. If you feel you can improve something, just shoot a proof of concept and I will gladly check and compare them, so we can all together choose the best one. |
@Gummibeer, I'm having to manually configure database because activitylog connection must be configured separately. But I now moved them all to :memory:. |
8cb5464
to
e3394e5
Compare
2ac3d99
to
18d8236
Compare
18d8236
to
102c177
Compare
All of your work is now on master after I rebased it and made it compatible with the changes coming from 1.2 and other changes for 2.0. This has been incredibly helpful and I can't thank you enough for this huge initiative for the future of Twill. Can't wait to announce 2.0 with more details about this PR! |
This is the initial test environment setup. It's not testing much yet.
It's testing, or loading
Testing tools/frameworks
We are using PHPUnit for unit tests, Testbench (also uses PHPUnit) for integration tests. In the future we shall need Laravel Dusk or Symfony Panther to execute browser (functional/acceptance) tests.
Database
We are using SQLite in :memory:.
Command line
There are some composer shortcuts:
composer test
Which execute tests, but of course you can still call
vendor/bin/phpunit
, andResponsible for running static analysis via PHPStan
Coverage
To look at the coverage page you just have to open its index.html file:
Badges
We could add some badges to the README.md if you like them:
Code Quality
We decided, for now, to use Scrutinizer CI, the preliminary result is in my personal repository:
https://scrutinizer-ci.com/g/antonioribeiro/twill/
Continuous Integration
TravisCI was selected to be our CI:
https://travis-ci.org/antonioribeiro/twill
Code Styling
We are still discussing this, we might go towards StyleCI but it will, probably, make a lot of changes in the current source code, so I think we should take it slowly.
New base namespaces for testing
I prefer to have my tests namespaced, to avoid conflicts, so that's why we now have some more:
A17\Twill\Tests\Unit
: unit testsA17\Twill\Tests\Integration
: integration testsApp
: this namespace is needed to test the instantiation of classes created by themodule
command, if, you find it pointless, we can ditch it in the future.Tools we still need to setup:
Travis must be turned on at: https://travis-ci.org/organizations/area17/repositories
Scrutinizer CI at: https://scrutinizer-ci.com/organizations/area17/repositories