test_case

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name                               = "create-test-case"
	AIGeneratedTestSetName             = "AI_Generated"
	AIGeneratedLevel2TestSetNamePrefix = "AI_"

	// OperationTypeGenerate 表示当前调用接口触发测试用例 生成 操作
	OperationTypeGenerate = "Generate"
	// OperationTypeSave 表示当前调用接口触发测试用例 保存 操作
	OperationTypeSave = "Save"

	I18nLang_zh_CN = "zh-CN"
	I18nLang_en_US = "en-US"
)

Variables

View Source
var GroupMessages json.RawMessage
View Source
var GroupSchema json.RawMessage

Functions

func GenerateGroupsForRequirements

func GenerateGroupsForRequirements(ctx context.Context, requirements []*apistructs.Issue, openaiURL *url.URL, xAIProxyModelId string) (requirementIdToGroups map[uint64][]string, err error)

func New

func New(ctx context.Context, prompt string, background *pb.Background) functions.Function

Types

type AICreateTestCasesResult

type AICreateTestCasesResult struct {
	IsSaveTestCasesSave bool              `json:"isTestCasesSaved,omitempty"`
	TestCases           interface{}       `json:"testcases,omitempty"`
	TestSetsInfo        TestcasesDirsInfo `json:"testSetsInfo,omitempty"`
}

AI 生成测试用例返回数据

type Function

type Function struct {
	// contains filtered or unexported fields
}

func (*Function) Callback

func (f *Function) Callback(ctx context.Context, arguments json.RawMessage, input interface{}) (any, error)

func (*Function) CompletionOptions

func (f *Function) CompletionOptions() []sdk.PatchOption

func (*Function) Description

func (f *Function) Description() string

func (*Function) Handler

func (f *Function) Handler(ctx context.Context, factory functions.FunctionFactory, req *pb.ApplyRequest, openaiURL *url.URL, xAIProxyModelId string) (any, error)

func (*Function) Name

func (f *Function) Name() string

func (*Function) RequestOptions

func (f *Function) RequestOptions() []sdk.RequestOption

func (*Function) Schema

func (f *Function) Schema() (json.RawMessage, error)

func (*Function) SystemMessage

func (f *Function) SystemMessage(lang string) string

func (*Function) UserMessage

func (f *Function) UserMessage() string

type FunctionParams

type FunctionParams struct {
	TestSetID    uint64          `json:"testSetID,omitempty"`
	SystemPrompt string          `json:"systemPrompt,omitempty"`
	Requirements []TestCaseParam `json:"requirements,omitempty"`
}

FunctionParams 解析 *pb.ApplyRequest 字段 FunctionParams

type GroupList

type GroupList struct {
	List []string `json:"list"`
}

type MessageByLanguage

type MessageByLanguage struct {
	TaskContent   string
	GroupContent  string
	GenerateTC    string
	GenerateGroup string
}

type RequireTestCaseIndex

type RequireTestCaseIndex struct {
	RequirementIndex int // aitestcase.FunctionParams.Requirements  的 index
	TestCaseIndex    int // aitestcase.FunctionParams.Requirements[].Reqs 的 index 列表
}

保存测试用例时,用于构建需求与测试用例的索引关联关系

type RequirementGroup

type RequirementGroup struct {
	ID     int64
	Groups []string
}

type SubDirs

type SubDirs struct {
	Dir           string    `json:"dir"`
	RequirementID uint64    `json:"requirementId,omitempty"`
	SubDirs       []SubDirs `json:"subDirs,omitempty"`
	Count         int       `json:"count,omitempty"`
}

type TestCaseCreateRequestList

type TestCaseCreateRequestList struct {
	List []apistructs.TestCaseCreateRequest `json:"list"`
}

type TestCaseFunctionInput

type TestCaseFunctionInput struct {
	TestSetParentID  uint64 // 生成的测试用例所在的测试集的父测试集 ID
	TestSetParentDir string // 生成的测试用例所在的测试集的父测试集 Directory
	TestSetID        uint64 // 生成的测试用例所在的测试集测 ID
	IssueID          uint64 // 生成的测试用例对应的需求的 ID
	Prompt           string // 为本次生成测试用例输入的 Prompt

	Name      string //生成的测试用例对应的按需求内容分组名称
	UserId    string
	ProjectId uint64
}

TestCaseFunctionInput 用于为单个需求生成测试用例的输入

type TestCaseParam

type TestCaseParam struct {
	IssueID          uint64                             `json:"issueID,omitempty"`
	Prompt           string                             `json:"prompt,omitempty"`
	ParentTestSetID  uint64                             `json:"parentTestSetID,omitempty"`  // 所属测试集的 Parent 测试集 ID
	ParentTestSetDir string                             `json:"parentTestSetDir,omitempty"` // 所属测试集的 Parent 测试集 Directory
	Reqs             []apistructs.TestCaseCreateRequest `json:"testCaseCreateReqs,omitempty"`
}

type TestcasesDirsInfo

type TestcasesDirsInfo struct {
	RootDir string    `json:"rootDir"`
	SubDirs []SubDirs `json:"subdirs"`
}

TestcasesDirsInfo 用于返回生成的测试集目录以及测试集中对应的测试用例的数量

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL