Skip to content

assert.Truef() works fine. require.Truef() results in undefined: require.Truef #468

@jaypipes

Description

@jaypipes

Based on the docs, there should be a require.Truef() function (and corresponding Assertions.Truef() method, however I'm getting an undefined: require.Truef when executing the following (using 1.1.4 release of testify):

$ cat sample_test.go 
package util

import (
    "testing"

    "github.com/stretchr/testify/assert"
    "github.com/stretchr/testify/require"
)

func TestAssert(t *testing.T) {
    val := true
    assert.Truef(t, true, "%v should be true.", val)
}

func TestRequire(t *testing.T) {
    val := true
    require.Truef(t, true, "%v should be true.", val)
}

results in:

$ go test ./...
sample_test.go:17: undefined: require.Truef

when I run a similar test with the Assertions.Truef() method, I get a similar failure:

$ cat sample_test.go 
package util

import (
    "testing"

    "github.com/stretchr/testify/assert"
    "github.com/stretchr/testify/require"
)

func TestAssert(t *testing.T) {
    assert := assert.New(t)
    val := true
    assert.Truef(true, "%v should be true.", val)
}

func TestRequire(t *testing.T) {
    require := require.New(t)
    val := true
    require.Truef(true, "%v should be true.", val)
}

results in a similar error:

$ go test ./...
sample_test.go:19: require.Truef undefined (type *require.Assertions has no field or method Truef)

Again, if I remove the requires example, everything works fine.

Any ideas?
-jay

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions