golang testify 测试库

项目仓库: https://github.com/stretchr/testifygit

debian 软件包: golang-github-stretchr-testify-devgithub

简单使用:golang

import (
      "testing"
      "github.com/stretchr/testify/assert"
    )

    func TestSomething(t *testing.T) {

      var a string = "Hello"
      var b string = "Hello"

      assert.Equal(t, a, b, "The two words should be the same.")

    }

stretchr/assert 包断言不会当即失败,而是返回一个 bool 值,若是想要当即失败,须要使用 stretchr/require 包。ui

相关文章
相关标签/搜索