test_gen_ai
library
Classes
AnalysisValidator
Validates that the generated test file has no Dart analysis errors.
ChatResponse
Represents a parsed response from Gemini model chat.
Declaration
Represents a code declaration extracted from Dart source files during
static analysis.
FormatValidator
Validates that the generated test file follows Dart formatting conventions.
GeminiChat
A wrapper around the Gemini ChatSession.
GeminiModel
A wrapper around the Gemini GenerativeModel for creating, configuring,
and interacting with Gemini model.
GenerationResponse
Result object returned after attempting to generate tests.
PromptGenerator
A utility for generating different LLM prompt templates for code
generation and analysis.
TestExecutionValidator
Validates that the generated tests executed successfully without failures.
TestGenerator
Class coordinates the LLM interaction, validation, and file writing
required to generate a valid test for a Dart source code.
ValidationResult
Validator
Interface for all validation checks that can be run on test files.
Properties
defaultValidators
→ List <Validator >
List of standard validators that are run on generated test files.
These validators must be passed before a test file is considered valid.
final
Functions
buildDependencyContext (Declaration declaration , {int maxDepth = 10 })
→ Map <Declaration ? , List <Declaration > >
Builds a context map for a given declaration, by traversing its
dependencies up to maxDepth levels deep.
Extracts Declaration s from the given package.
Extracts declarations that have untested code lines based on coverage data.
formatContext (Map <Declaration ? , List <Declaration > > parentMap )
→ String
Formats the context map produced by buildDependencyContext into a
human-readable string, including code snippets and their file paths.
formatCoverage (Map <String , dynamic > coverageResults , String packageDir )
→ Future <CoverageData >
Formats raw coverage results into a CoverageData structure.
formatUntestedCode (Declaration declaration , List <int > lines )
→ String
Returns the code for declaration after marking the specified lines
as untested, and wrapping it in the parent declaration's context if exists.
runTestsAndCollectCoverage (String packageDir , {String vmServicePort = '0' , bool branchCoverage = false , bool functionCoverage = false , bool isInternalCall = false , required Set <String > scopeOutput })
→ Future <Map <String , dynamic > >
Runs Dart tests in the specified packageDir and collects coverage data.
validateTestCoverageImprovement ({required Declaration declaration , required int baselineUncoveredLines , required String packageDir , required Set <String > scopeOutput , String vmServicePort = '0' , bool branchCoverage = false , bool functionCoverage = false })
→ Future <bool >
Called after generating a test for the given declaration to check whether
coverage improved by comparing current uncovered lines with those
before the test was generated.