-
Notifications
You must be signed in to change notification settings - Fork 220
Allow running tests by line and column #1604
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
Changes from 12 commits
d48656f
336e451
e5bbd56
067cfbe
ca9d827
1a82532
307cd27
8c9c045
b9c65d6
81f0320
0f4b7f9
3cce004
946bf28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,17 +173,41 @@ description (including any group descriptions) match that regular expression | |
will be run. You can also use the `-N` flag to run tests whose names contain a | ||
plain-text string. | ||
|
||
Alternatively, you can filter tests by name only for a specific file/directory | ||
by specifying a query on a path: `dart test "path/to/test.dart?name=test name"`. | ||
That ensures that the name filters applies to one path but not others. | ||
|
||
By default, tests are run in the Dart VM, but you can run them in the browser as | ||
well by passing `dart test -p chrome path/to/test.dart`. `test` will take | ||
care of starting the browser and loading the tests, and all the results will be | ||
reported on the command line just like for VM tests. In fact, you can even run | ||
tests on both platforms with a single command: `dart test -p "chrome,vm" | ||
path/to/test.dart`. | ||
|
||
### Test Path Queries | ||
|
||
Some query parameters are supported on test paths, which allow you to filter the | ||
tests that will run within just those paths. These filters are merged with any | ||
global options that are passed, and all filters must match for a test to be ran. | ||
|
||
- **name**: Works the same as `--name` (simple contains check). | ||
- This is the only option that supports more than one entry. | ||
- **full-name**: Requires an exact match for the name of the test. | ||
- **line**: Matches any test that originates from this line in the test suite. | ||
- **col**: Matches any test that originates from this column in the test suite. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused who would use this? Is this a specific column? Like the position of the first There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes - only IDEs would use it most likely There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason for it is protection against accidentally running tests the user doesn't expect if they have duplicate names: // Click "Run" next to this test currently runs both tests, which seems odd to the user
test('foo', () {});
test('foo', () {}); Although the IDE will need to be sure of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ya and having the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still don't understand the precise position this matches. Is it exactly the first I'll read through the test cases tomorrow to find out more, but I do think we should expand the user facing docs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It matches the column position of the function invocation in the stack trace. That is the position of the first character of the name of the function (so if your cursor is to the left of it). It is one based, which matches what the IDE reports (or at least VsCode, I assume this is standard?).
There is a sentence after these that says "all filters must match for a test to be ran". I could move it to the top? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok I added a mini section under this describing the specific line/col semantics, and also moved the note about all filters matching up to the first paragraph. |
||
|
||
**Example Usage**: `dart test "path/to/test.dart?line=10&col=2"` | ||
|
||
#### Line/Col Matching Semantics | ||
|
||
The `line` and `col` filters match against the current stack trace taken from | ||
the invocation to the `test` function, and are considered a match if | ||
**any frame** in the trace meets **all** of the following criteria: | ||
|
||
* The URI of the frame matches the root test suite uri. | ||
* This means it will not match lines from imported libraries. | ||
* If both `line` and `col` are passed, both must match **the same frame**. | ||
* The specific `line` and `col` to be matched are defined by the tools creating | ||
the stack trace. This generally means they are 1 based and not 0 based, but | ||
this package is not in control of the exact semantics and they may vary based | ||
on platform implementations. | ||
|
||
### Sharding Tests | ||
Tests can also be sharded with the `--total-shards` and `--shard-index` arguments, | ||
allowing you to split up your test suites and run them separately. For example, | ||
|
Uh oh!
There was an error while loading. Please reload this page.