yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::cli::automation::TestGenerationAPI Class Reference

API for automated test generation and execution. More...

#include <test_generation_api.h>

Classes

struct  CoverageReport
 Coverage report for tested code. More...
 
struct  GenerationOptions
 Options for test generation. More...
 
struct  RecordedInteraction
 Recorded interaction for test generation. More...
 
struct  RecordingSession
 Test recording session. More...
 
struct  TestResult
 Test execution result. More...
 
struct  TestSpecification
 Generate test from specification. More...
 

Public Types

enum class  TestFramework { GTEST , CATCH2 , DOCTEST , IMGUI_TEST }
 
using RecordingCallback = std::function<void(const RecordedInteraction&)>
 
using GenerationCallback = std::function<void(const std::string& progress)>
 

Public Member Functions

absl::Status StartRecording (const std::string &test_name, bool capture_state=true)
 Start recording user interactions.
 
absl::StatusOr< RecordingSessionStopRecording ()
 Stop current recording session.
 
void PauseRecording ()
 Pause recording temporarily.
 
void ResumeRecording ()
 Resume paused recording.
 
void AnnotateRecording (const std::string &annotation)
 Add annotation to current recording.
 
absl::StatusOr< std::string > GenerateTestFromRecording (const RecordingSession &session, const GenerationOptions &options={})
 Generate test code from recording.
 
absl::StatusOr< std::string > GenerateTestSuite (const TestSpecification &spec, const GenerationOptions &options={})
 Generate comprehensive test suite from specification.
 
absl::StatusOr< std::string > GenerateRegressionTest (const std::string &bug_description, const std::vector< std::string > &repro_steps, const std::string &expected_behavior, const GenerationOptions &options={})
 Generate regression test from bug report.
 
absl::StatusOr< std::string > GenerateFixture (app::editor::Editor *editor, const std::string &fixture_name)
 Generate test fixture from current editor state.
 
absl::StatusOr< std::string > GenerateMock (const std::string &interface_name, const std::string &mock_name)
 Generate mock object for testing.
 
absl::StatusOr< TestResultExecuteGeneratedTest (const std::string &test_code, bool compile_only=false)
 Execute generated test code.
 
absl::StatusOr< std::vector< TestResult > > RunTestFile (const std::string &test_file, const std::string &filter="")
 Run existing test file.
 
absl::StatusOr< CoverageReportGenerateCoverageReport (const std::vector< TestResult > &test_results)
 Generate coverage report for tests.
 
std::vector< std::string > ValidateTestCode (const std::string &test_code)
 Validate generated test code.
 
std::map< std::string, std::vector< std::string > > CheckRequirementsCoverage (const std::string &test_code, const std::vector< std::string > &requirements)
 Check if test covers specified requirements.
 
absl::StatusOr< nlohmann::json > SuggestTestCases (const std::string &code_under_test, const std::string &model_name="gemini")
 Use AI model to suggest test cases.
 
absl::StatusOr< std::string > ImproveTest (const std::string &test_code, const std::vector< std::string > &improvement_goals)
 Use AI to improve existing test.
 
nlohmann::json OrganizeTestSuites (const std::vector< std::string > &test_files)
 Organize tests into suites.
 
absl::StatusOr< std::string > GenerateTestDocumentation (const std::string &test_file, const std::string &format="markdown")
 Generate test documentation.
 
void SetRecordingCallback (RecordingCallback callback)
 Set callback for recording events.
 
void SetGenerationCallback (GenerationCallback callback)
 Set callback for generation progress.
 

Private Member Functions

std::string GenerateTestHeader (const GenerationOptions &options) const
 
std::string GenerateTestBody (const RecordingSession &session, const GenerationOptions &options) const
 
std::string GenerateAssertion (const RecordedInteraction &interaction, TestFramework framework) const
 
absl::Status CompileTest (const std::string &test_code) const
 

Private Attributes

std::unique_ptr< RecordingSessioncurrent_recording_
 
bool is_recording_ = false
 
bool is_paused_ = false
 
RecordingCallback recording_callback_
 
GenerationCallback generation_callback_
 

Detailed Description

API for automated test generation and execution.

Enables AI agents to generate, execute, and validate tests for YAZE components. Supports recording user interactions, generating regression tests, and creating comprehensive test suites.

Definition at line 26 of file test_generation_api.h.

Member Typedef Documentation

◆ RecordingCallback

Definition at line 318 of file test_generation_api.h.

◆ GenerationCallback

using yaze::cli::automation::TestGenerationAPI::GenerationCallback = std::function<void(const std::string& progress)>

Definition at line 319 of file test_generation_api.h.

Member Enumeration Documentation

◆ TestFramework

Enumerator
GTEST 
CATCH2 
DOCTEST 
IMGUI_TEST 

Definition at line 32 of file test_generation_api.h.

Member Function Documentation

◆ StartRecording()

absl::Status yaze::cli::automation::TestGenerationAPI::StartRecording ( const std::string & test_name,
bool capture_state = true )

Start recording user interactions.

Parameters
test_nameName for the test being recorded
capture_stateIf true, capture full editor state at each step
Returns
Status of recording start

◆ StopRecording()

absl::StatusOr< RecordingSession > yaze::cli::automation::TestGenerationAPI::StopRecording ( )

Stop current recording session.

Returns
Recorded session or error

◆ PauseRecording()

void yaze::cli::automation::TestGenerationAPI::PauseRecording ( )

Pause recording temporarily.

◆ ResumeRecording()

void yaze::cli::automation::TestGenerationAPI::ResumeRecording ( )

Resume paused recording.

◆ AnnotateRecording()

void yaze::cli::automation::TestGenerationAPI::AnnotateRecording ( const std::string & annotation)

Add annotation to current recording.

Parameters
annotationComment or description to add

◆ GenerateTestFromRecording()

absl::StatusOr< std::string > yaze::cli::automation::TestGenerationAPI::GenerateTestFromRecording ( const RecordingSession & session,
const GenerationOptions & options = {} )

Generate test code from recording.

Parameters
sessionRecorded session to convert
optionsGeneration options
Returns
Generated test code or error

◆ GenerateTestSuite()

absl::StatusOr< std::string > yaze::cli::automation::TestGenerationAPI::GenerateTestSuite ( const TestSpecification & spec,
const GenerationOptions & options = {} )

Generate comprehensive test suite from specification.

Parameters
specTest specification
optionsGeneration options
Returns
Generated test code or error

◆ GenerateRegressionTest()

absl::StatusOr< std::string > yaze::cli::automation::TestGenerationAPI::GenerateRegressionTest ( const std::string & bug_description,
const std::vector< std::string > & repro_steps,
const std::string & expected_behavior,
const GenerationOptions & options = {} )

Generate regression test from bug report.

Parameters
bug_descriptionDescription of the bug
repro_stepsSteps to reproduce
expected_behaviorExpected correct behavior
optionsGeneration options
Returns
Generated regression test or error

◆ GenerateFixture()

absl::StatusOr< std::string > yaze::cli::automation::TestGenerationAPI::GenerateFixture ( app::editor::Editor * editor,
const std::string & fixture_name )

Generate test fixture from current editor state.

Parameters
editorEditor to capture state from
fixture_nameName for the fixture class
Returns
Generated fixture code or error

◆ GenerateMock()

absl::StatusOr< std::string > yaze::cli::automation::TestGenerationAPI::GenerateMock ( const std::string & interface_name,
const std::string & mock_name )

Generate mock object for testing.

Parameters
interface_nameInterface to mock
mock_nameName for mock class
Returns
Generated mock code or error

◆ ExecuteGeneratedTest()

absl::StatusOr< TestResult > yaze::cli::automation::TestGenerationAPI::ExecuteGeneratedTest ( const std::string & test_code,
bool compile_only = false )

Execute generated test code.

Parameters
test_codeGenerated test code
compile_onlyIf true, only compile without running
Returns
Test results or error

◆ RunTestFile()

absl::StatusOr< std::vector< TestResult > > yaze::cli::automation::TestGenerationAPI::RunTestFile ( const std::string & test_file,
const std::string & filter = "" )

Run existing test file.

Parameters
test_filePath to test file
filterOptional test filter pattern
Returns
Test results or error

◆ GenerateCoverageReport()

absl::StatusOr< CoverageReport > yaze::cli::automation::TestGenerationAPI::GenerateCoverageReport ( const std::vector< TestResult > & test_results)

Generate coverage report for tests.

Parameters
test_resultsResults from test execution
Returns
Coverage report or error

◆ ValidateTestCode()

std::vector< std::string > yaze::cli::automation::TestGenerationAPI::ValidateTestCode ( const std::string & test_code)

Validate generated test code.

Parameters
test_codeCode to validate
Returns
List of validation issues (empty if valid)

◆ CheckRequirementsCoverage()

std::map< std::string, std::vector< std::string > > yaze::cli::automation::TestGenerationAPI::CheckRequirementsCoverage ( const std::string & test_code,
const std::vector< std::string > & requirements )

Check if test covers specified requirements.

Parameters
test_codeTest code to analyze
requirementsList of requirements to check
Returns
Coverage mapping of requirements to test cases

◆ SuggestTestCases()

absl::StatusOr< nlohmann::json > yaze::cli::automation::TestGenerationAPI::SuggestTestCases ( const std::string & code_under_test,
const std::string & model_name = "gemini" )

Use AI model to suggest test cases.

Parameters
code_under_testCode to generate tests for
model_nameAI model to use (e.g., "gemini", "ollama")
Returns
Suggested test cases as JSON

◆ ImproveTest()

absl::StatusOr< std::string > yaze::cli::automation::TestGenerationAPI::ImproveTest ( const std::string & test_code,
const std::vector< std::string > & improvement_goals )

Use AI to improve existing test.

Parameters
test_codeExisting test code
improvement_goalsWhat to improve (coverage, performance, etc.)
Returns
Improved test code or error

◆ OrganizeTestSuites()

nlohmann::json yaze::cli::automation::TestGenerationAPI::OrganizeTestSuites ( const std::vector< std::string > & test_files)

Organize tests into suites.

Parameters
test_filesList of test files
Returns
Organization structure as JSON

◆ GenerateTestDocumentation()

absl::StatusOr< std::string > yaze::cli::automation::TestGenerationAPI::GenerateTestDocumentation ( const std::string & test_file,
const std::string & format = "markdown" )

Generate test documentation.

Parameters
test_fileTest file to document
formatDocumentation format (markdown, html, etc.)
Returns
Generated documentation or error

◆ SetRecordingCallback()

void yaze::cli::automation::TestGenerationAPI::SetRecordingCallback ( RecordingCallback callback)

Set callback for recording events.

◆ SetGenerationCallback()

void yaze::cli::automation::TestGenerationAPI::SetGenerationCallback ( GenerationCallback callback)

Set callback for generation progress.

◆ GenerateTestHeader()

std::string yaze::cli::automation::TestGenerationAPI::GenerateTestHeader ( const GenerationOptions & options) const
private

◆ GenerateTestBody()

std::string yaze::cli::automation::TestGenerationAPI::GenerateTestBody ( const RecordingSession & session,
const GenerationOptions & options ) const
private

◆ GenerateAssertion()

std::string yaze::cli::automation::TestGenerationAPI::GenerateAssertion ( const RecordedInteraction & interaction,
TestFramework framework ) const
private

◆ CompileTest()

absl::Status yaze::cli::automation::TestGenerationAPI::CompileTest ( const std::string & test_code) const
private

Member Data Documentation

◆ current_recording_

std::unique_ptr<RecordingSession> yaze::cli::automation::TestGenerationAPI::current_recording_
private

Definition at line 332 of file test_generation_api.h.

◆ is_recording_

bool yaze::cli::automation::TestGenerationAPI::is_recording_ = false
private

Definition at line 333 of file test_generation_api.h.

◆ is_paused_

bool yaze::cli::automation::TestGenerationAPI::is_paused_ = false
private

Definition at line 334 of file test_generation_api.h.

◆ recording_callback_

RecordingCallback yaze::cli::automation::TestGenerationAPI::recording_callback_
private

Definition at line 335 of file test_generation_api.h.

◆ generation_callback_

GenerationCallback yaze::cli::automation::TestGenerationAPI::generation_callback_
private

Definition at line 336 of file test_generation_api.h.


The documentation for this class was generated from the following file: