Open jorgecoca opened 2 years ago
There seems to be some workarounds, like explained here: https://github.com/dart-lang/dart-pad/wiki/Embedding-Guide#testing-the-users-code
However, I don't think that's a good example or experience since it deviates from the standard way of testing using test
/flutter_test
.
Kinda need the ability to run user generated code under a test runner in a sandbox on the server. That's probably do-able under Cloud Run using gvisor for sandboxing, but it isn't going to be a cakewalk.
@RedBrogdon explored creating a custom test package for DartPad based codelabs which could be explored further: https://github.com/RedBrogdon/dartpad_test
@RedBrogdon are you up for publishing your package on pub.dev? Currently we only add packages via pub.dev...
Any updates on this? If we had this, we could add tests to all tutorials, which would bring more people into contact with tests and how to write tests. It would also enable tutorials on writing tests with interactive examples rather than just video/ code listings.
As a developer, I find DartPad incredibly useful to learn and teach easy to semi-complex Flutter/Dart topics in a preconfigured environment, and that's priceless.
However, one thing I wish DartPad had to make it 💯 would be the ability to write and run automated tests against the code written in the main workspace.
Why you might be wondering? 🤔
Flutter/Dart has an incredible opportunity to elevate the coding practices of the community overall. It is quite common these days to see open sources projects of all kinds written in Flutter/Dart to include a strong battery of tests. Even our loved
counter
project includes a file with a simple widget test, encouraging developers to keep improving on those tests. And, at the same time, I have not seen other similar tools offering something like this. Testing tends to be an after thought in other stacks, but not in Dart/Flutter.I think having the option to add tests in DartPad, especially in combination with other tools like workshops, could be an incredible teaching tool that would educate developers not only on writing beautiful UI experiences but also writing robust automated tests that maintain the fidelity of those experiences over time.
I know many unicorns 🦄 working with me that would love this functionality.
Thank you!