internal

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FieldInfo

type FieldInfo struct {
	// インタフェースか否か
	IsInterface bool
	// パッケージ名
	PackageName string
	// 型名
	TypeName string
	// テンプレートのパラメータに用いる型名
	UpperCamelCaseTypeName string
}

FieldInfo フィールド情報

type IFDepMethod

type IFDepMethod interface {
	GetPosition() token.Pos
}

type MockMethod

type MockMethod struct {
	// メソッドを持つフィールド
	Field string
	// メソッド名
	Name string
	// ASTにおける出現位置
	Position token.Pos
	// 引数の数
	ArgLen int
	// 戻り値の数
	ReturnLen int
}

MockMethod モック化するメソッド

func (*MockMethod) GetPosition

func (m *MockMethod) GetPosition() token.Pos

type TargetMethod

type TargetMethod struct {
	// メソッド名
	Name string
	// ASTにおける出現位置
	Position token.Pos
}

TargetMethod テスト対象のメソッド

func (*TargetMethod) GetPosition

func (m *TargetMethod) GetPosition() token.Pos

type TemplateMockMethod

type TemplateMockMethod struct {
	// メソッド名
	Name string
	// ASTにおけるメソッドの位置
	Position int
	// 引数(nil*引数の数)
	Arg string
	// 戻り値(nil*戻り値の数)
	Return string
}

TemplateMockMethod テンプレートのパラメータ用のmock化するメソッド

type TemplateParams

type TemplateParams struct {
	// テスト対象メソッドを持つ構造体のフィールドの情報
	FieldMap map[string]*FieldInfo
	// テスト対象メソッドごとのテストケースの情報
	TargetMethodTesCasesMap map[string][]*UpdateTestCase
}

TemplateParams jsonに渡すパラメータ

func CreateTemplateParams

func CreateTemplateParams(t *TestFile) *TemplateParams

CreateTemplateParams テスト対象のファイルから抽出した情報(*TestFile)を元にテンプレートのパラメータを返す

func (*TemplateParams) ToJson

func (t *TemplateParams) ToJson() ([]byte, error)

type TestCase

type TestCase struct {
	// テストケースの分岐点となるif文の行数
	Line int
	// 正常系か
	IsSuccessPattern bool
	// contains filtered or unexported fields
}

TestCase テストケース

type TestFile

type TestFile struct {
	// テスト対象のメソッドを持つ構造体のフィールド情報を管理
	FieldMap map[string]*FieldInfo
	// 各テスト対象のメソッドのテストケース一覧を管理
	TargetMethodTesCasesMap map[string][]*TestCase
}

TestFile テスト対象ファイルのASTから抽出した値を格納する構造体

func GetAnalysisResult

func GetAnalysisResult(astF *ast.File, fset *token.FileSet, packageTypes *types.Package) (*TestFile, error)

GetAnalysisResult ASTから値を抽出し、テンプレートのパラメータ用の構造体を生成する

type UpdateTestCase

type UpdateTestCase struct {
	// テストケースの分岐点となる行数
	Line int
	// 正常系のテストケースか否か
	IsSuccessPattern bool
	// テストケース内で利用されている各フィールドのメソッド群
	DepMethodsInField map[string][]*TemplateMockMethod
}

UpdateTestCase テンプレートのパラメータ用に更新されたテストケース

Jump to

Keyboard shortcuts

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