alsatian icon indicating copy to clipboard operation
alsatian copied to clipboard

Setup and teardown hooks that runs before and after ALL test suites executed?

Open georgyfarniev opened this issue 6 years ago • 3 comments

It would be nice to have setup and teardown hooks that executes before ALL fixtures ONCE and teradown after ALL fixtures ONCE in addition to fixture hooks.

For example, it is convenient for setup test environment globally only once before all tests via hooks instead of creating custom singleton

georgyfarniev avatar Dec 16 '18 03:12 georgyfarniev

I would say in general this is a bad idea of you can avoid it as there's a risk of making tests flaky or having setup that's unclear in the scope of the test.

Have you got an example use case?

jamesadarich avatar Dec 18 '18 18:12 jamesadarich

I would say in general this is a bad idea of you can avoid it as there's a risk of making tests flaky or having setup that's unclear in the scope of the test.

Have you got an example use case? A good example is when we need to create and initialize test database, especially if it takes long time for unit tests to run before each suite.

georgyfarniev avatar Jan 02 '19 11:01 georgyfarniev

Ah I see. In these cases I usually set this up before Alsatian is even called. Do you think there would be a benefit in having Alsatian handle this?

An example of the above would be

npm run setup:database && alsatian "./**/*.spec.js"

jamesadarich avatar Jan 02 '19 11:01 jamesadarich