google / google/json_serializable.dart

Build Failure with Dart Test's Tags Annotation

Open
#1,480 0 comments 1 reaction 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.