vendredi 5 juin 2020

Dart library: export a file from the test folder

My library's structure is:

mylib lib mylib.dart src example.dart test utilities.dart

I'd like to export some helper functions I've written in this library so they can be used in the test files of other libraries.

In mylib.dart, which contains exports for the other classes in the library (e.g. export 'src/example.dart';, the following line causes an error:

export '../test/utilities.dart';

The error is:

Target of URI doesn't exist: '../test/serialization_testing.dart'.

It seems I can only export files under the lib folder. I imagine this is a security thing, so I don't go exporting files from just anywhere on my computer.

Is it possible to export a file that contains utility functions for tests, if that file lives under the test folder? Or should I put those utility functions in a file under the lib folder, even though they only pertain to testing, and should only be used in other libraries' tests?

Aucun commentaire:

Enregistrer un commentaire