modelina
modelina copied to clipboard
Add runtime tests for Dart
Reason/Context
To properly test that the models that are generated are semantically correct, we need to test them in their specific runtime. This means that we need to add the setup for Dart.
We already have a bunch of existing runtime tests for the other languages, that you can use as reference implementation: https://github.com/asyncapi/modelina/tree/master/test/runtime
Here is the TODO to solve this issue:
- Create a simple Dart project under
runtime-dart
that has a simple testing setup - Add a simple generation script called
runtime-dart.ts
that generates the models: https://github.com/asyncapi/modelina/blob/master/test/runtime/runtime-kotlin.ts - Add a simple TS test file that is used in the ecosystem to test the runtime: https://github.com/asyncapi/modelina/blob/master/test/runtime/runtime-kotlin.spec.ts
- Add two scripts to the package.json file called
test:runtime:dart
andgenerate:runtime:dart
- Add a GitHub workflow file that spins up the test: https://github.com/asyncapi/modelina/blob/master/.github/workflows/runtime-kotlin-testing.yml
- Manually add a dart test that makes sure that the generated dart model can be used as expected.
That should be it to add runtime testing.
If you encounter any problems just reach out :v:
While testing the generated Dart code from the generic-input.json using the dart run
command within the runtime-dart
folder, I am getting the following error.
Building package executable...
Failed to build runtime_dart:runtime_dart:
lib/Address.dart:1:8: Error: Error when reading 'lib/nested_object.dart': No such file or directory
import 'package:runtime_dart/nested_object.dart';
^
since the file generated from the generator is NestedObject.dart
and not nested_object.dart
. any suggestions how can I move ahead. In my investigation I found that Dart supports snake-case
for packages.
Also, as I'm not very much familiar with Dart language, it would be a great help if you can tell me how to write the entry point
code for the runtime-dart.dart
file here.
Cant help you much with dart unfortunately... Maybe try and reach out on the AsyncAPI slack channel #tooling