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
Labels
Milestone

Comments

@adhithya-srinivasan
Copy link

@adhithya-srinivasan adhithya-srinivasan commented May 23, 2020

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
@gopherbot gopherbot added the Proposal label May 23, 2020
@tmthrgd
Copy link
Contributor

@tmthrgd 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 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 Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.