Agreed
On Nov 19, 2010, at 12:34 PM, Patrick Steele <[email protected]> wrote: > Sure, that'll work too. But its a new instance for each test. That's > what I was getting at. Using a single mock instance across different > tests is something I don't like doing. > > --- > Patrick Steele > http://weblogs.asp.net/psteele > > > > On Fri, Nov 19, 2010 at 11:21 AM, Tim Barcz <[email protected]> wrote: >> What about sharing a mock that is populated in [Setup] and set to null in >> [Teardown]? I've done/do this and when a change comes up I deal with it at >> that time. >> Tim >> >> >> On Fri, Nov 19, 2010 at 10:16 AM, Patrick Steele <[email protected]> >> wrote: >>> >>> Ok, fair enough (although this is usually the time when I say you >>> should be looking for a new job with a better company that values the >>> input of its developers...) >>> >>> Back to the original question: Don't re-use a mock object across >>> multiple tests. Your tests should be running totally in isolation and >>> if a single mock is used across multiple tests, your tests aren't >>> isolated (side effects of operations in one test could affect the >>> results of another test). And I can almost guarantee you that at some >>> point in the future, someone will need something slightly different >>> with that mock, they'll change it for their test and every other test >>> in the class will break. >>> >>> Just create the new mock using the code you posted at the beginning of >>> each test. >>> >>> --- >>> Patrick Steele >>> http://weblogs.asp.net/psteele >>> >>> >>> >>> On Fri, Nov 19, 2010 at 3:36 AM, rssole <[email protected]> wrote: >>>> Unfortunately, it is not up to me it is (more or less) matter of >>>> politics and this particular environment, >>>> where on build server as part of CI where tests are also run, there >>>> also 3.5 is not available. >>>> But that is completely another story... >>>> >>>> >>>> On Nov 18, 5:55 pm, Patrick Steele <[email protected]> wrote: >>>>> You could make things easier by having your unit tests written for >>>>> .NET 3.5, but your application code can still target 2.0. I did this >>>>> a lot when the company I was working for was slow to push 3.5 out to >>>>> the users. Devs had it on their machines (and we're the only ones >>>>> that ran the unit tests), so we used Rhino.Mocks + .NET 3.5 in the >>>>> unit tests. >>>>> >>>>> --- >>>>> Patrick Steelehttp://weblogs.asp.net/psteele >>>>> >>>>> On Thu, Nov 18, 2010 at 11:46 AM, rssole <[email protected]> wrote: >>>>>> Perhaps someone will wonder why using full static invocation syntax >>>>>> instead of extensions, delegates instead of lambdas etc. >>>>>> well I am refactoring and adding unit tests to some old .net 2.0 (c# >>>>>> 2.0) project where extensions and other c# 3.0 stuff is out of reach >>>>>> :) >>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Rhino.Mocks" group. >>>>>> To post to this group, send email to [email protected]. >>>>>> To unsubscribe from this group, send email to >>>>>> [email protected]. >>>>>> For more options, visit this group >>>>>> athttp://groups.google.com/group/rhinomocks?hl=en. >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Rhino.Mocks" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> For more options, visit this group at >>>> http://groups.google.com/group/rhinomocks?hl=en. >>>> >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Rhino.Mocks" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/rhinomocks?hl=en. >>> >> >> >> >> -- >> Tim Barcz >> Microsoft C# MVP >> Microsoft ASPInsider >> http://timbarcz.devlicio.us >> http://www.twitter.com/timbarcz >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Rhino.Mocks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/rhinomocks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Rhino.Mocks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rhinomocks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rhinomocks?hl=en.
