Repository navigation
feat: Add Serverpod test tools - #2713
Merged
hampuslavin merged 23 commits intoSep 17, 2024
Merged
Conversation
hampuslavin
force-pushed
the
hl_test_framework_with_serverpod
branch
4 times, most recently
from
September 10, 2024 14:49
8a2b96e to
daf648e
Compare
To be continued in a follow-up issue
hampuslavin
force-pushed
the
hl_test_framework_with_serverpod
branch
3 times, most recently
from
September 11, 2024 07:07
5883bf6 to
35d6da5
Compare
hampuslavin
force-pushed
the
hl_test_framework_with_serverpod
branch
from
September 11, 2024 07:16
35d6da5 to
77e4726
Compare
hampuslavin
marked this pull request as ready for review
September 11, 2024 07:18
hampuslavin
requested review from
Isakdl,
SandPod,
christerswahn and
vlidholt
September 11, 2024 07:27
hampuslavin
commented
Sep 11, 2024
SandPod
reviewed
Sep 11, 2024
SandPod
left a comment
Contributor
There was a problem hiding this comment.
Dumping a first session of comments now after looking at the tests. Review is not complete but it seems like my review tab is slowing down.
SandPod
previously requested changes
Sep 11, 2024
SandPod
left a comment
Contributor
There was a problem hiding this comment.
Awesome work with all of this.
I have a bunch of comments and questions.
Please look them through and ping me when it is time for a re-review or if you have any questions.
The changelog in the new project should inlcude all the other changelogs.
I think you can add these by running the util/update_pubspecs script
Isakdl
reviewed
Sep 12, 2024
…e session is unique for each call
hampuslavin
commented
Sep 13, 2024
Worked because of transaction bug fixed in a separate PR: serverpod#2749
…also solves the "null/undefined" problem.
hampuslavin
force-pushed
the
hl_test_framework_with_serverpod
branch
from
September 16, 2024 11:07
5606bd4 to
b257a14
Compare
4 of 6 tasks
Isakdl
reviewed
Sep 17, 2024
Isakdl
reviewed
Sep 17, 2024
Isakdl
approved these changes
Sep 17, 2024
Isakdl
left a comment
Collaborator
There was a problem hiding this comment.
This is huge! Been on my whish list since day one ❤️!
LGTM 🚀 🚀 🚀
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Introduces the "alpha version" of the new Serverpod test tools, as outlined on a high level here (specifically item 2 and 3 on the roadmap at the bottom).
The main feature is the
withServerpodhelper:endointsobject that enables the user to easily test all their endpointssessionobject that lets the user call endpoints and the database just like they are used to. To customize the session state, the user simply callscopyWith.copyWithat the moment isauthenticationInfo. As we go forward we will explore what the needs are and extend with more properties here, e.g. cache and message central.tests are wrapped in database transactions which automatically rolls back the database after each test caseSee the
tests/serverpod_test_server/test_integration/test_tools/*folder for comprehensive examples of all capabilities.💡 The test tools will be generated if the
server_test_tools_pathkey is specified inconfig/generator.yaml. Since the templates are not updated in this PR, this is not exposed by default. Once it's production ready, the template will specify a default test tools path.💡 As you will see,
withServerpodis not exported byserverpod_testdirectly but from the generated test tools file. The main benefit from doing it like this is that this completely removes the need for boiler plate code. Since using generated code is already done in other places, it doesn't go against the paradigm of the Serverpod framework.Changes
serverpod_testpackage that contains the business logic for the test helpertestmode, but will be finished in a follow-up PR (see Follow-up issues below)tests/serverpod_test_server/test_integration/test_tools/*. The goal is that these tests should be the source of truth of all the capabilities of the test helper. Therefore, these tests are written from the perspective of an end user.DatabaseAccessorinterface to enable the automatic rollback feature in testsRecommended reviewing
tests/serverpod_test_server/test_integration/test_tools/*folder to see how the test tool is used for different use casesFollow-up issues [WIP]
There are a few things that needs to be fixed before this can be exposed publicly. See full list below:
ExitExceptioninServerpod.startinstead of exiting process #2725Pre-launch Checklist
///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.