Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test status does not flow from TestSetup to its running Test #128

Open
christothes opened this issue Apr 3, 2021 · 1 comment · May be fixed by #127
Open

Test status does not flow from TestSetup to its running Test #128

christothes opened this issue Apr 3, 2021 · 1 comment · May be fixed by #127

Comments

@christothes
Copy link

christothes commented Apr 3, 2021

Given a test suite with a TestSetup method, if c.Fail() is called on the *C instance captured from the TestSetup method or one of its descendants after TestSetup completes but before the Test method completes, the test is not marked failed.

Consider the following test:

package main

import (
	chk "gopkg.in/check.v1"
	"testing"
)

type scratchTest struct {
	c *chk.C
}

// Hookup to the testing framework
func Test(t *testing.T) { chk.TestingT(t) }

var _ = chk.Suite(&scratchTest{})

func (s *scratchTest) TestCheckDoesNotFlow(c *chk.C) {
	s.doFail()
	c.Log("This test should be failing")
}

func (s *scratchTest) SetUpTest(c *chk.C) {
	// capture the check test context
	s.c = c
}

func (s *scratchTest) doFail() {
	s.c.Fail()
}

Actual output:

OK: 1 passed
PASS
ok      _/C_/src/goscratch      0.126s

Expected output:

----------------------------------------------------------------------
FAIL: checkrepro_test.go:20: scratchTest.TestCheckDoesNotFlow

This test should be failing
OOPS: 0 passed, 1 FAILED
--- FAIL: Test (0.00s)
FAIL
exit status 1
FAIL    chrissscratch.com/scratch       0.105s
@christothes christothes linked a pull request Apr 3, 2021 that will close this issue
@barrettj12
Copy link

Duplicate of #22 and #41

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants