Skip to content

Commit 5cc0c21

Browse files
authored
Update build_test/README.md. (#4051)
1 parent ef9ecd1 commit 5cc0c21

File tree

3 files changed

+14
-32
lines changed

3 files changed

+14
-32
lines changed

_test/test/sub-dir/subdir_test.dart

Lines changed: 0 additions & 12 deletions
This file was deleted.

build_test/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
sources visible to the test into memory.
88
- `testBuilder` default `onLog` now works outside of tests: it falls
99
back to `print` instead of crashing.
10+
- Update `README.md`.
1011

1112
## 3.0.0
1213

build_test/README.md

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ add to your `pubspec.yaml`:
2323

2424
```yaml
2525
dev_dependencies:
26-
build_test:
26+
build_test: ^3.0.0
2727
```
2828
2929
## Running tests
@@ -79,17 +79,20 @@ creates an in-memory representation of various utility classes.
7979

8080
### Exposing actual package sources to `testBuilder`
8181

82-
You can expose real package sources to the builder in addition to your in
83-
memory sources, by passing a `PackageAssetReader` to the `reader` parameter:
82+
To pass sources on disk to `testBuilder`, create a `TestReaderWriter`. You can
83+
write individual sources to it from a `PackageAssetReader`, or write all sources
84+
to it with `loadIsolateSources`:
8485

8586
```dart
86-
testBuilder(yourBuilder, {}/* test assets here */,
87-
reader: await PackageAssetReader.currentIsolate());
87+
final readerWriter = TestReaderWriter();
88+
await readerWriter.loadIsolateSources();
89+
testBuilder(
90+
yourBuilder,
91+
{} /* test assets here */,
92+
readerWriter: readerWriter,
93+
);
8894
```
8995

90-
You can pass any custom AssetReader here, which will be used as a fallback
91-
for any source not defined in the source assets map.
92-
9396
### Resolve source code for testing
9497

9598
Using [`resolveAsset`][api:resolveAsset] and
@@ -112,25 +115,15 @@ test('should resolve a simple dart file', () async {
112115
### Various test implementations of classes
113116

114117
* [`FakeWatcher`][api:FakeWatcher]
115-
* [`InMemoryAssetReader`][api:InMemoryAssetReader]
116-
* [`InMemoryAssetWriter`][api:InMemoryAssetWriter]
117-
* [`MultiAssetReader`][api:MultiAssetReader]
118+
* [`TestReaderWriter`][api:TestReaderWriter]
118119
* [`PackageAssetReader`][api:PackageAssetReader]
119-
* [`RecordingAssetWriter`][api:RecordingAssetWriter]
120-
* [`StubAssetReader`][api:StubAssetReader]
121-
* [`StubAssetWriter`][api:StubAssetWriter]
122120

123121
[development dependency]: https://dart.dev/tools/pub/dependencies#dev-dependencies
124122
[`package:build`]: https://pub.dev/packages/build
125123

126124
[api:FakeWatcher]: https://pub.dev/documentation/build_test/latest/build_test/FakeWatcher-class.html
127-
[api:InMemoryAssetReader]: https://pub.dev/documentation/build_test/latest/build_test/InMemoryAssetReader-class.html
128-
[api:InMemoryAssetWriter]: https://pub.dev/documentation/build_test/latest/build_test/InMemoryAssetWriter-class.html
129-
[api:MultiAssetReader]: https://pub.dev/documentation/build_test/latest/build_test/MultiAssetReader-class.html
125+
[api:TestReaderWriter]: https://pub.dev/documentation/build_test/latest/build_test/TestReaderWriter-class.html
130126
[api:PackageAssetReader]: https://pub.dev/documentation/build_test/latest/build_test/PackageAssetReader-class.html
131-
[api:RecordingAssetWriter]: https://pub.dev/documentation/build_test/latest/build_test/RecordingAssetWriter-class.html
132-
[api:StubAssetReader]: https://pub.dev/documentation/build_test/latest/build_test/StubAssetReader-class.html
133-
[api:StubAssetWriter]: https://pub.dev/documentation/build_test/latest/build_test/StubAssetWriter-class.html
134127

135128
[api:resolveAsset]: https://pub.dev/documentation/build_test/latest/build_test/resolveAsset.html
136129
[api:resolveSource]: https://pub.dev/documentation/build_test/latest/build_test/resolveSource.html

0 commit comments

Comments
 (0)