How to FailNow during SetupSuite?

Open
#849 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
go
Domain
testing-qa

Research direction

Start by tracing the suite lifecycle around SetupSuite, suite.T().FailNow(), and TearDownSuite. Confirm the current behavior with a focused Go test that fails during setup, then determine the intended cleanup semantics and document or test the resulting behavior.

Written by the indexing model from the issue text.

Description

I'm writing a testing suite that spins up some resource on SetupSuite (in my case a virtual machine), runs some tests against it, then destroys the resource on TearDownSuite.

Now, sometimes the resource may fail to spin up or have some issue with it which makes running the tests useless, in which case I'd like to suite.T().FailNow(). However, if you run suite.T().FailNow() during SetupSuite then the TearDownSuite never runs, which could lead to the VM not being destroyed & could lead to dangling/costly VMs.

Is this by design? If so, how could I go about solving my issue.

Dominant language
Go
Stars
26.2k
Forks
1.9k
Avg merge
2d 4h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stretchr/testify

All issues in stretchr/testify

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.