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

proposal: Global setup teardown and configure method similar to rspec-ruby spec_helper for testing package #39222

Closed
adhithya-srinivasan opened this issue May 23, 2020 · 2 comments

Comments

@adhithya-srinivasan
Copy link

In ruby rspec test framework we have spec_helper.rb to include methods like

RSpec.configure do |config|
c.before(:suite) { establish_connection }
end

which will run before and after specs ran.

Can we implement something similar to the above in our go lang testing package so that we can do global before and after configurations before and after running suite or each tests?

@adhithya-srinivasan adhithya-srinivasan changed the title Proposal - Global setup teardown and configure method similar to rspec-ruby spec_helper for testing package proposal: Global setup teardown and configure method similar to rspec-ruby spec_helper for testing package May 23, 2020
@gopherbot gopherbot added this to the Proposal milestone May 23, 2020
@tmthrgd
Copy link
Contributor

tmthrgd commented May 23, 2020

You can already do this If needed by defining a TestMain function. See the testing package docs: https://golang.org/pkg/testing/#hdr-Main.

@rsc
Copy link
Contributor

rsc commented Jun 10, 2020

This is a duplicate of #27927. The resolution was explained in #27927 (comment).

TestMain or subtests are the suggested answer here.

Closing as duplicate of #27927.

@rsc rsc closed this as completed Jun 10, 2020
@golang golang locked and limited conversation to collaborators Jun 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants