testify icon indicating copy to clipboard operation
testify copied to clipboard

Set up objects once and reuse across multipe suites/tests

Open Victor-Chirinian-Vimeo opened this issue 3 years ago • 1 comments

Hello, I am wondering if testify has test session level capabilities, similar to frameworks like python or nunit ? If not, has anyone come up with an efficient way of reusing instantiated objects across multiple suites, without having to call the same boilerplate code over again ?

Pytest example:

@pytest.fixture(scope="session")
def create_client_once():
    ## code to create http client once..
    yield client

Victor-Chirinian-Vimeo avatar Jun 01 '22 20:06 Victor-Chirinian-Vimeo

May be I got you wrong, but it's possible to create them on package level and use them from functions. Like

package main_test

var (
    someIntance *client
)


func TestSomeThing(t *testing.T) {
...
}

lisitsky avatar Aug 16 '22 19:08 lisitsky