Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the test suite setup method executed once for each test, or only once for all?

I know the answer may differ for each test framework. But for the ones you know, what should happen?

like image 755
Jader Dias Avatar asked Apr 29 '10 19:04

Jader Dias


Video Answer


2 Answers

In NUnit, you have TestFixtureSetUp which runs only once before all tests in the fixture run and SetUp which runs before each test method is run.

like image 111
uvita Avatar answered Nov 04 '22 00:11

uvita


In MSTest you have TestInitializeAttribute

When run in a load test, the method marked with this attribute will run once for every virtual user iteration in the test. If you need to do initialization operations once, that apply to the entire test, use the ClassInitializeAttribute.

AssemblyInitializeAttribute is run once for all tests in all classes.

like image 42
Jader Dias Avatar answered Nov 04 '22 00:11

Jader Dias