tag:blogger.com,1999:blog-5359546512544809971.post7891687379207133455..comments2024-03-22T10:42:37.237-07:00Comments on Jeremy Bytes: Unit Testing: Setup Methods or Not?Jeremyhttp://www.blogger.com/profile/06749690234470413216noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-5359546512544809971.post-20449486647169881312016-09-10T04:34:44.346-07:002016-09-10T04:34:44.346-07:00I usually use setup in my integration tests to cle...I usually use setup in my integration tests to clean database, setup Ninject and other stuff like that but never ever for getting and instance of a mock object. When you put something in the setup method, you glue all your test to have to use all the time this code. Just to prevent having to write 2 or 3 additional lines of code in each test... For sure that I prefer more lines of code in this case yes for the readability but also for the maintainability and flexibility that it gives to me.Samuelhttps://www.blogger.com/profile/18140931118197628245noreply@blogger.comtag:blogger.com,1999:blog-5359546512544809971.post-58948842511094751662015-06-09T07:37:20.935-07:002015-06-09T07:37:20.935-07:00Good explanation as usual! I like the setup method...Good explanation as usual! I like the setup method because I'm really lazy but the factory method is just as simple and the added line in "Arrange" really improves the readability of the test. Thanks also for your contribution at the Denver Dev Day!Anonymoushttps://www.blogger.com/profile/17310670150656828281noreply@blogger.comtag:blogger.com,1999:blog-5359546512544809971.post-29589228864709869662015-06-09T04:41:22.143-07:002015-06-09T04:41:22.143-07:00I completely agree. Usually a setup method means s...I completely agree. Usually a setup method means splitting your test into several region and in some unit testing framework having a shared state between the tests.<br />In the last year I have been using Automocking containers to reduce the overhead of creating the same objects over and over again: http://blog.drorhelper.com/2013/12/on-object-creation-and-unit-tests.htmlAnonymoushttps://www.blogger.com/profile/04664241287712801778noreply@blogger.com