Dartdoc_test reports no tests run when everything works
Given this lib/abd.dart
/// This class is excellent
/// ```dart
/// void main() {
/// print('hi');
/// main();
/// }
/// ```
class Foo {}
> dart test
00:01 +0: loading test/dartdoc_test.dart Extracting code samples ...
Analyzing code samples ...
No tests ran.
No tests were found.
I would have expected at least a single test to have run. If I make a syntax error it does indeed report a failed test.
@takumma FYI, in case you're interested.
The issue I analyzed is that the dartdoc_test doesn't recognize or detect the test running inside the documentation.
Solution I proposed:
Modify test/dartdoc_test.dart to explicitly scan and run the code samples in lib/abd.dart
syntax:
import 'package:dartdoc_test/dartdoc_test.dart';
// main definition void main () { testDartdocExamples('lib/abd.dart'); }
Why this is helpful:
The tool might not automatically detect the test, so explicitly registering it forces dartdoc_test to analyze lib/abd.dart.
to run:
dart test