All Projects → issue9 → assert

issue9 / assert

Licence: MIT license
Go 语言 assert 断言函数

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to assert

type-guards
Simple utility for runtime type checking which also assigns the correct type if used with TypeScript.
Stars: ✭ 30 (+76.47%)
Mutual labels:  assert, assertion
Strikt
An assertion library for Kotlin
Stars: ✭ 310 (+1723.53%)
Mutual labels:  test, assert
jest-expect-contain-deep
Assert deeply nested values in Jest
Stars: ✭ 68 (+300%)
Mutual labels:  test, assertion
Testify
A unit testing framework written in bash for bash scripts
Stars: ✭ 45 (+164.71%)
Mutual labels:  test, assert
got
An enjoyable golang test framework.
Stars: ✭ 234 (+1276.47%)
Mutual labels:  test, assert
Assert
A collection of convenient assertions for Swift testing
Stars: ✭ 69 (+305.88%)
Mutual labels:  test, assert
beekeeper
Swarm Beekeeper is an orchestrator that can manage a cluster of Bee nodes and call into their API. It allows various scenario’s to be performed on these nodes. The Swarm team uses Beekeeper internally for integration tests.
Stars: ✭ 51 (+200%)
Mutual labels:  test
pynvme
builds your own tests.
Stars: ✭ 139 (+717.65%)
Mutual labels:  test
vscode-phpunit
The VS Code Test Explorer extension for PHPUnit
Stars: ✭ 100 (+488.24%)
Mutual labels:  test
lwc-test
LWC plugins and utilities for testing
Stars: ✭ 39 (+129.41%)
Mutual labels:  test
phoenix.webui.framework
基于WebDriver的WebUI自动化测试框架
Stars: ✭ 118 (+594.12%)
Mutual labels:  test
assert-never
Helper function for exhaustive checks of discriminated unions in TypeScript
Stars: ✭ 32 (+88.24%)
Mutual labels:  assert
Caraya
Assertion and unit test framework for LabVIEW
Stars: ✭ 45 (+164.71%)
Mutual labels:  test
Android-Test
Android测试中常用到的脚本
Stars: ✭ 17 (+0%)
Mutual labels:  test
dextool
Suite of C/C++ tooling built on LLVM/Clang
Stars: ✭ 81 (+376.47%)
Mutual labels:  test
arduino-ci-script
Bash script for continuous integration of Arduino projects
Stars: ✭ 25 (+47.06%)
Mutual labels:  test
htest
htest is a http-test package
Stars: ✭ 24 (+41.18%)
Mutual labels:  test
elastic-search-test
ESIntegTestCase example
Stars: ✭ 17 (+0%)
Mutual labels:  test
can-npm-publish
A command line tool that check to see if `npm publish` is possible.
Stars: ✭ 61 (+258.82%)
Mutual labels:  test
eat
Json based scenario testing tool(which can have test for functional and non-functional)
Stars: ✭ 41 (+141.18%)
Mutual labels:  test

assert

Go codecov license PkgGoDev Go version

assert 包是对 testing 的一个简单扩展,提供的一系列的断言函数, 方便在测试函数中使用:

func TestA(t *testing.T) {
    v := true
    a := assert.New(t, false)
    a.True(v)
}

// 也可以对 testing.B 使用
func Benchmark1(b *testing.B) {
    a := assert.New(b, false)
    v := false
    a.True(v)
    for(i:=0; i<b.N; i++) {
        // do something
    }
}

// 对 API 请求做测试,可以引用 assert/rest
func TestHTTP( t *testing.T) {
    a := assert.New(t, false)

    srv := rest.NewServer(a, h, nil)
    a.NotNil(srv)
    defer srv.Close()

    srv.NewRequest(http.MethodGet, "/body").
        Header("content-type", "application/json").
        Query("page", "5").
        JSONBody(&bodyTest{ID: 5}).
        Do().
        Status(http.StatusCreated).
        Header("content-type", "application/json;charset=utf-8").
        JSONBody(&bodyTest{ID: 6})
}

也可以直接对原始数据进行测试。

// 请求数据
req :=`POST /users HTTP/1.1
Host: example.com
Content-type: application/json

{"username": "admin", "password":"123"}

`

// 期望的返回数据
resp :=`HTTP/1.1 201
Location: https://example.com/users/1
`

func TestRaw(t *testing.T) {
    a := assert.New(t, false)
    rest.RawHTTP(a, nil,req, resp)
}

版权

本项目采用 MIT 开源授权许可证,完整的授权说明可在 LICENSE 文件中找到。

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].