Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dartdoc_test reports no tests run when everything works #250

Open
sigurdm opened this issue Sep 2, 2024 · 2 comments
Open

Dartdoc_test reports no tests run when everything works #250

sigurdm opened this issue Sep 2, 2024 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers pkg:dartdoc_test

Comments

@sigurdm
Copy link
Collaborator

sigurdm commented Sep 2, 2024

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.

@sigurdm sigurdm added pending-triage Issue is pending triage pkg:dartdoc_test labels Sep 2, 2024
@jonasfj jonasfj added bug Something isn't working good first issue Good for newcomers and removed pending-triage Issue is pending triage labels Sep 4, 2024
@jonasfj
Copy link
Member

jonasfj commented Sep 4, 2024

@takumma FYI, in case you're interested.

@Hira-Iftikhar-123
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers pkg:dartdoc_test
Projects
None yet
Development

No branches or pull requests

3 participants