Repository navigation
Conversation
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
provokateurin
left a comment
There was a problem hiding this comment.
I'm strongly in favor of going with PHPUnit.
Would we be able to directly use code from server inside the tests, e.g. to set config options instead of having to go through the OCS APIs? That would be a major benefit IMO.
I think if those are integration tests, then I guess we should not access internals to set the state. Fredinand's example is using occ to set the config for example. I would also be in favor of PHPUnit, it is faster than cypress, and it is already known. Only caveat, as it needs a live instance, we need to provide a good way of running the tests locally, just like we are doing with the current ones. Using PHPUnit is the way we went for Circles (example). It is more barebone than your example, and uses internal code to set the state as Kate suggested. But I think your way of provinding primitives to set the state is much cleaner. Also, unsure how to manage the test accross the entire test suite of server, which is massive. Not sure how the current ones are doing it. I think to remember that nothing specific is done, so changing one test could afect another one. Small rant: I think all our PHPUnit tests that access the DB should eventually be integration tests like in your example, so that actual unit tests can run without a live instance. |
Yes, I just think it would make the tests execute faster and easier to write. |
Motivation
Every time we discussed integration tests it was concluded that no backend engineer liked the BDD tests (behat integration tests) as the gherkin language just adds a artificial language layer on top of the PHP fixtures.
But no non-technical person ever worked on the tests, meaning the one argument for such gherkin tests is not fulfilled.
Writing new integration tests is a burden that prevents many needed regression tests and thus negatively affects the Nextcloud QA.
There are various solutions available as alternatives, I have considered following approaches:
PEST
Pest is a slim framework on-top of PHPUnit it allows for slimmer test case code as you no longer need to write full test classes but just use functional approach
test('what i am testing', function () { expect(1)->toBe(1); }).PHPUnit
Use PlayWright
Comparison
As PEST only is a layer on top of PHPUnit I skipped this for the proof of concept, I personally also do not think it makes sense to introduce this new test pattern in Nextcloud backend.
For performance:
The test was a bit unfair as it mostly waits for the rate limit to cooldown, so a test like the sharing features is most likely much faster on Playwright than on the others as it can make use of fully parallel web requests.
Summary
I think that both alternatives Playwright and PHPUnit have their benefits so this is up for a discussion of all contributors.
From my point of view both are better readable and maintainable as an software engineer when compared with behat - at least when working in the Nextcloud ecosystem.
Checklist
3. to review, feature component)stable32)AI (if applicable)