|
From: Owen R. <OR...@th...> - 2004-09-30 04:27:12
|
ah i see... you're looking for a way to inject mocks for acceptance/regression/integration testing... while you can use nmock to accomplish this sort of task, the framework was not designed with this in mind. nmock, like most mocking frameworks is intended to help drive the design of code using unit tests. it is used to design and test the interaction between dependent objects, not for layer-based testing. nat pryce has a very nice blog entry on the subject: http://nat.truemesh.com/archives/000342.html that said, here's one suggestion for how you can use nmock to accomplish your task. if you can avoid having to work with persistent mocks, it will make your life much easier. the challenge is to figure out how to inject in-memory mocks into your code. my recommendation is to try using picocontainer and constructor-based dependency injection; however, this may require a radically change to your architecture. alternately, you can use service locators (which is kind of like what you already have). martin fowler has a nice article describing these two approaches: http://martinfowler.com/articles/injection.html cheers, owen. --- R. Owen Rogers ThoughtWorks Technologies (India) Pvt Ltd. ThoughtWorks - Deliver with passion! ThoughtWorks is always looking for talented people who are passionate about technology. To find out more about a career at ThoughtWorks go to http://www.thoughtworks.com/career/. <vas...@ac...> 29/09/2004 19:40 To: "Owen Rogers" <OR...@th...> cc: <nmo...@li...> Subject: Re: Some clarifications required on NMock Hi Owen, Thanks for the reply. Actually our development code will look like the below one. class XFactory { //.... some code Public X GetXInstance { get { if(InUnitTest) { retyrn return XMock } else { return realX } } } } I hope this will gives the information required. with regds, vasu Owen Rogers <OR...@th... To: Vasu Devan/Internal/Accenture@Accenture m> cc: nmo...@li... Subject: Re: Some clarifications required on NMock 09/29/2004 06:16 PM hi vasu, > Is it possible to save the Mock class generated by Nmock. currently no (at least as far as i understand your question). could you please explain further why you might want to do this? i'm not sure if i understand what you mean by "later time compilation and customization". cheers, owen. ps. in future, please address your queries to the list (nmo...@li...) rather than directly to the maintainers. --- R. Owen Rogers ThoughtWorks Technologies (India) Pvt Ltd. ThoughtWorks - Deliver with passion! ThoughtWorks is always looking for talented people who are passionate about technology. To find out more about a career at ThoughtWorks go to http://www.thoughtworks.com/career/. <vas...@ac...> To: cc: 29/09/2004 18:51 Subject: Some clarifications required on NMock Hi, We have a question on NMock. Is it possible to save the Mock class generated by Nmock. Whether the Mock classes will be available in the disk for later time compilation and customization. Pls give me these answers. with regds, vasu This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. |