google/dart-neats

Feature request: actually run tests

Open

#252 opened on Sep 2, 2024

View on GitHub
 (0 comments) (3 reactions) (0 assignees)Dart (93 forks)auto 404
enhancementhelp wantedpkg:dartdoc_test

Repository metrics

Stars
 (508 stars)
PR merge metrics
 (PR metrics pending)

Description

It would be awesome to be able to write tests like:

/// ```dart#test
/// assert(add2(3) == 6);
/// ```
int add2(int x) => x+2

And have the code actually run as a test something like:

> dart test
00:02 +0 -1: test/dartdoc_test.dart: [dartdoc_test] lib/abc.dart test for error [E] 
'abc.dart': Failed assertion: line 1 pos 10: 'add2(3) == 6': is not true.
#0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:50:61)
#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2      main (file:///usr/local/google/home/sigurdm/projects/blah/ddt/bin/a.dart:2:10)
#3      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#4      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

Contributor guide