modelina icon indicating copy to clipboard operation
modelina copied to clipboard

Add runtime tests for Dart

Open jonaslagoni opened this issue 6 months ago • 3 comments

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 and generate: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:

jonaslagoni avatar Jan 12 '24 01:01 jonaslagoni

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.

akkshitgupta avatar Jan 28 '24 17:01 akkshitgupta

Cant help you much with dart unfortunately... Maybe try and reach out on the AsyncAPI slack channel #tooling

jonaslagoni avatar Jan 28 '24 23:01 jonaslagoni