
I am trying to test my dart functions locally before I deploy them to the cloud. Sadly with the new update to v1.4 I can no longer set the req.variables with the needed variables. In my head there are these options for testing functions:
- Testing locally and setting the Platform.environment variables (How?)
- Creating a real execution on cloud (Cant do that bc of the dart / dart_appwrite version)
- Integreation test from flutter App
Since my tests worked locally I would really like to just modify them slightly to work again. Has someone an Idea how to do that?
And in general, what is expected to be the best practice for testing the functions?
Thanks for your help in advance! <:appwriteheart2:1073243188954935387>

I highly suggest testing in Appwrite. one way is to use a local instance of Appwrite. The reason why I would test in Appwrite and build incrementally is to make sure things work incrementally. There could be something different between your simulated local test and Appwrite where it works locally, but not in Appwrite and if you have hundreds of lines of code, it may be difficult to figure out what part is causing the problem

Ok my problem with testing directly in appwrite is splitted. Firstly I am unpatient and do not want to wait for the build process of the function 😉 Secondly and more important, for developing the functions for cloud I have installed dart 2.17 which is not compatible with dart_appwrite higher than 8.0.1. With this setup I am not able to call createExecution with the newly published options like body or headers. So I would have to install another dart version just to test the function?

Hi @whataboutno13
I encountered a similar scenario, where I prefer testing my functions locally for more straightforward debugging prior to running in Appwrite.
Unfortunately altering the Platform.environment during runtime isn’t possible. There is a request for this feature in the Dart language repository, but I couldn't find the issue at the moment.
I discovered two potential workarounds.
- Use --define // --dart-define when running the functions and access via String.fromEnvironment.
2.Create your own RuntimeRequest, add an environment variable, and then insert logic in your code to distinguish between locally test and appwrite.. Example check if the variable exists in Platform.environment. If absent, presume it's a test and utilize the added environment variable instead.
I did go for the second alternative at the moment. I do find option 1 more cleaner, and will probably go for that in the future.
I hope this helps you, let me know if you have any questions.

Hi @freppsa, thank you for your response! My solution for local testing right now is actually setting my windows environment variables to the required ones from my functions. Not ideal but this way I do not have to distinguish between local test and appwrite cloud. Still not an optimal solution.
I mean local testing makes debugging and stuff so much easier, thats why I am confused why its so focused on testing only in appwrite. Feels like going directly going into integration testing and leaving unit testing behind. Or am I wrong about this? 🤔

That’s an third option! Yes I completely agree - i do unit testing and integration testing locally and only after that I deploy functions to an test instance.
Recommended threads
- Pro Plan additonal resources
When on the Pro plan do you automatically get charged for more resources, or is they charges you can add on if you need more resources? eg. Functions says "$2 ...
- Assistance Required: Error While Claimin...
I have registered for the 100 Agents Hackathon and received the promotional offer to claim $50 in credits for Appwrite Cloud Pro. However, while attempting to r...
- Choose SMTP per email
Hi, I'm looking quite some time for the answer but can't find one. Do any of you know if it is possible to use a specific SMTP provider per message (email). E.g...
