I am trying to figure out difference between SetupSuite
and SetupTest
for quite some time now. Based on information on blogs I have understood that SetupSuite
is run before entire suite and SetupTest
runs before each test case. But what could be practical example in such a case? And how does dependency injection differ in both the cases?
Asked
Active
Viewed 4,523 times
1

Mohit Jain
- 733
- 3
- 9
- 24
-
1Just as you said--one runs before the entire suite of tests, the other before an individual test. I'm not sure what further clarification is possible or desired. – Jonathan Hall May 06 '18 at 15:30
-
Any practical example where anyone is preferred over other? – Mohit Jain May 07 '18 at 04:39
1 Answers
4
Generally you want to use SetupTest
so that each individual test function runs with a clean environment. SetupSuite
is useful in cases where the setup code is time consuming and isn't modified in any of the tests. An example of when this could be useful is if you were testing code that reads from a database, and all the tests used the same data and only ran SELECT
statements. In this scenario, SetupSuite
could be used once to load the database with data.

phiggy
- 898
- 8
- 9