
kevmoo/source_gen_test
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
パッケージ:source gen ジェネレーターの堅牢なテストを作成する API をテスト
概要
パッケージ:source gen から派生したジェネレーターを、テストファイルをアノテーションすることで簡単にテストできます。 出力自体でテストを書くこともできます。 cartesianProduct と checkGeneratorBatch を使用して、AST/declaration の大きな行列を 1 つの共有パッケージでジェネレータまたは GeneratorForAnnotation に対して検証します。:analyzer コンテキストと一括分離します。 spawnUriランタイムパス: パッケージ:source gen test は、ストレステストジェネレータと GeneratorForAnnotation の実装のためのバンドルされたソース ジェネ テスト ファズ エージェント スキルを出荷します。 パッケージが dev dependencies で source gen test に依存している場合は、パッケージ:skills で依存関係からすべてのバンドルされたスキルをインストールします。 GitHubから直接スキルをインストールするか:
概要(AI 翻訳)
package:source_genから派生した[Generators]を簡単にテストできます
テストファイルを注釈付けします。
出力にテストを書きたい場合、金色の出力ファイルに対してテスト それ自体。
その他ヘルパーもご用意しています。
結合バッチ検証([verifyGeneratorBatch)
[cartesianProduct と verifyGeneratorBatch] を使用して、大きなマトリックスを検証します。
[Generatorまたは[GeneratorForAnnotationに対してAST/declarationのpermutations]
単一の共有で [package:analyzer] コンテキストとバッチ [Isolate.spawnUri]]
runtime パス:
##AIエージェントスキル([[T9])
[package:source_gen_test バンドル
[source-gen-test-fuzz エージェントスキル
ストレステスト Generator と GeneratorForAnnotation] の実装
[cartesianProduct と [verifyGeneratorBatch] 。
パッケージが dev_dependencies で source_gen_test に依存している場合、すべてのインストール
あなたの依存関係から束縛されたスキル
[package:skills]:
GitHubから直接スキルをインストールするか:
このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。
README
Make it easy to test Generators derived from package:source_gen by
annotating test files.
@ShouldGenerate(
r'''
const TestClass1NameLength = 10;
const TestClass1NameLowerCase = 'testclass1';
''',
configurations: ['default', 'no-prefix-required'],
)
@ShouldThrow(
'Uh...',
configurations: ['vague'],
element: false,
)
@TestAnnotation()
class TestClass1 {}
Test against a golden output file if you also want to write tests on the output itself.
part 'goldens/testclass2.dart';
@ShouldGenerateFile(
'goldens/testclass2.dart',
partOfCurrent: true,
configurations: ['default', 'no-prefix-required'],
)
@ShouldThrow(
'Uh...',
configurations: ['vague'],
element: false,
)
@TestAnnotation()
class TestClass2 {}
Other helpers are also provided.
Combinatorial Batch Verification (verifyGeneratorBatch)
Use cartesianProduct and verifyGeneratorBatch to validate large matrices of
AST/declaration permutations against a Generator or GeneratorForAnnotation
in a single shared package:analyzer context and batched Isolate.spawnUri
runtime pass:
final axes = cartesianProduct({
'fieldType': ['int', 'int?', 'List'],
'includeIfNull': ['true', 'false'],
});
final report = await verifyGeneratorBatch(
generator: MyGenerator(),
imports: const ["import 'package:my_pkg/annotations.dart';"],
cases: [
for (var i = 0; i < axes.length; i++)
CodegenCase(
id: 'case_$i',
declarations: '''
@MyAnnotation(includeIfNull: ${axes[i]['includeIfNull']})
class Case$i {
final ${axes[i]['fieldType']} value;
Case$i(this.value);
}
''',
runtimeCheck: 'final c = Case$i(null);',
),
],
);
AI Agent Skill (source-gen-test-fuzz)
package:source_gen_test ships a bundled
source-gen-test-fuzz agent skill for
stress-testing Generator and GeneratorForAnnotation implementations with
cartesianProduct and verifyGeneratorBatch.
If your package depends on source_gen_test in dev_dependencies, install all
bundled skills from your dependencies with
package:skills:
dart run skills@ get
Or install the skill directly from GitHub:
dart run skills@ add kevmoo/source_gen_test --skill source-gen-test-fuzz
# or
npx skills add kevmoo/source_gen_test --skill source-gen-test-fuzz
推奨ツール
別のキーワードを試すか、フィルタを外してください。
インストール
npx skillfish add kevmoo/source_gen_test