gtest

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

gtesting 包

简介

gtesting 包提供了测试相关的工具函数。

功能特性

  • 断言工具:便捷的测试断言
  • Mock 工具:模拟对象
  • 测试辅助:测试辅助函数

安装

go get github.com/snail007/gmc/util/testing

快速开始

package main

import (
    "testing"
    "github.com/snail007/gmc/util/testing"
)

func TestExample(t *testing.T) {
    // 断言相等
    gtesting.Equal(t, 1+1, 2)
    
    // 断言不为 nil
    gtesting.NotNil(t, &struct{}{})
    
    // 断言为真
    gtesting.True(t, true)
}

相关链接

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebugRunProcess

func DebugRunProcess(t *testing.T)

func InGMCT

func InGMCT() bool

func RunProcess

func RunProcess(t *testing.T, f func()) bool

RunProcess checking if testing is called in NewProcess, if true, then call the function f and returns true, you should return current testing t function after call CanExec.

Types

type Process

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

func NewProcess

func NewProcess(t *testing.T) *Process

NewProcess fork a subprocess runs current testing t function.

func (*Process) IsRunning

func (s *Process) IsRunning() bool

IsRunning returns true if testing subprocess is running, otherwise returns false.

func (*Process) Kill

func (s *Process) Kill() (err error)

Kill killing testing subprocess.

func (*Process) Output

func (s *Process) Output() string

Output acquires the subprocess stdout and stderr output after Start called.

func (*Process) Start

func (s *Process) Start() (err error)

Start starts testing subprocess and return immediately with no wait.

func (*Process) Verbose

func (s *Process) Verbose(isVerbose bool) *Process

Verbose sets verbose output of testing process.

func (*Process) Wait

func (s *Process) Wait() (out string, exitCode int, err error)

Wait starts testing subprocess and wait for it exited.

Jump to

Keyboard shortcuts

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