zdpgo_test

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 28, 2022 License: MIT Imports: 2 Imported by: 0

README

zdpgo_testify

基于testify二次封装的测试框架

版本历史

  • v0.1.0 2022/04/12 断言功能
  • v0.1.1 2022/04/26 优化:代码结构调整
  • v0.1.2 2022/05/28 优化:代码结构调整

使用案例

断言功能
package main

import (
	""
	"testing"
)

func TestCalculate(t *testing.T) {
	test := zdpgo_test.New()
	test.SetTestObj(t)

	// 创建表格
	var tests = []struct {
		input    int // 输入
		expected int // 期望输出
	}{
		{2, 4},
		{-1, 1},
		{0, 2},
		{-5, -3},
		{99999, 100001},
	}

	// 遍历表格数据
	for _, testData := range tests {
		// 断言
		test.Assert.Equal(Calculate(testData.input), testData.expected)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	TestObj *testing.T // 测试对象
}

type Test

type Test struct {
	Assert *assert.Assertions
	Config *Config
}

func New

func New() *Test

New 新建测试对象

func NewWirthConfig

func NewWirthConfig(config Config) *Test

NewWirthConfig 根据配置新建测试对象

func (*Test) SetTestObj

func (t *Test) SetTestObj(t1 *testing.T)

SetTestObj 测试测试对象

Directories

Path Synopsis
Package difflib is a partial port of Python difflib module.
Package difflib is a partial port of Python difflib module.
examples
Package spew implements a deep pretty printer for Go data structures to aid in debugging.
Package spew implements a deep pretty printer for Go data structures to aid in debugging.
Package yaml implements YAML support for the Go language.
Package yaml implements YAML support for the Go language.

Jump to

Keyboard shortcuts

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