google / google/json_serializable.dart
Build Failure with Dart Test's Tags Annotation
- Dominant language
- Dart
- Stars
- 1.6k
- Forks
- 461
- Avg merge
- 45m
- Merged PRs (30d)
- 1
Description
When using the [Tags annotation](https://pub.dev/packages/test#tagging-tests) for `dart test`, build runner fails with the following exception:
```
[SEVERE] json_serializable on test/integration_test.dart:
Could not resolve annotation for `library asset:my_project/test/integration_test.dart`.
```
I was able to reproduce the issue by:
- Creating `test/integration_test.dart` (below)
- Running builder runner
- It didn't fail the first time, so I modified the file and ran it again, which then triggered the above build failure.
test/integration_test.dart:
```dart
@Tags(['integration-test']) // <-- Causes build_runner failure
library;
import 'package:test/test.dart';
void main() {
test("example test", () {});
}
```
As a workaround, you can add the following to your `build.yaml`:
```yaml
targets:
$default:
sources:
exclude:
- test/integration_test.dart
```
Of course, this only works if your tests don't rely on build_runner, so a more permanent solution would be most welcome.
Contributor guide
Assessment
This issue has not been assessed yet.