简体   繁体   中英

Prepare Integration Test test data only once for ALL Unit Tests

集成测试Test_Method应该调用一次其单独的测试数据,还是应该在每个Test_Method之前调用的Setup方法中为ALL Test_Methods设置测试数据?

It depends if your tests are changing the values of the test data - because it could cause your subsequent tests to fail if value a is updated by test 1 to value b...and test 2 expects value b.

Otherwise, if your tests only read data and don't change it then you could setup the data once, using something like NUnits [TestFixtureSetup] attribute, rather than the individual tests [SetUp] attribute, which you should use if you need the data resetting each time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM