kumbhkaran_21 wrote:
> While doing TDD a scenario,we needed some objects which had
> data.But,since we did not want to hit the database,we created these
> objects in code,and initialized them with some values.We did not
> assign values to all the properties.Is it the right thing to do?
I think so. That describes how I use test doubles more than any other
way. I would call these "fakes" rather than "mocks" because they're
just faking data rather than checking expectations. They're no less
useful for that, though. The terminology just helps to make you
description clear when talking with other people.
> Also,can we use mock frameworks to mock concrete objects?
Some mock frameworks can work with concrete classes, and some are
restricted to interfaces. I haven't kept up with all the frameworks,
but I think you'll find plenty that can do that for you.
While doing TDD a scenario,we needed some objects which had data.But,since we did not want to hit the database,we created these objects in code,and initialized...
Vishal, ... I think so. That describes how I use test doubles more than any other way. I would call these "fakes" rather than "mocks" because they're just...
In cases like yours, where you are really just trying to pass in a data object, it is simpler just to populate a real object if you can. Mocking a data object...
Hello, kumbhkaran_21. On Saturday, November 24, 2007, at 7:06:10 ... Did tell you what you wanted to know? Did it permit you to go forward with more...
... Often no, they've been for mocking interfaces instead. Stupid languages with interfaces. ... J. B. (Joe) Rainsberger :: http://www.jbrains.ca Your guide to...
... You can use JMock and its friends along with the gclib to create test doubles for concrete classes that have a public, no-argument constructor. What you...
... Sounds like it. One of our "test smells" in our Synaesthesia series is trying to mock value objects. ... Most of them will, but I don't recommend it. S ...
... "Most of them will, but I don't recommend it." Would that be a smell to look out for? Mocking a concrete class with no interface? Wouldn't it also smell if...
... I believe so. I mostly want to do it when working with legacy code, where its stench is so easily overpowered by the stenches around it. ... I don't...
... to me it would. Maybe the class should be used directly in the test. ... Not necessarily. I use interfaces more than many others to identify the roles that...
What I'm wondering about is actually when creating a new class... and it's going to be a dependency of another class... are you saying to by default give it an...
... For me, it depends. If you know Domain-Driven Design's terms, then I never expect interfaces for Values, sometimes for Entities and always for Services....
... Your rules about when to use interfaces in the domain seem sensible to me, though we don't even put interfaces on services until there is a need (and so...
... You don't test that your Front Controller correctly dispatches to the appropriate Service? Maybe you don't because you don't have to write code for that. ...
... Sorry yeah, but we use TypeMock so we'd be testing against the concrete class. ... In my experience its common to have logic within one domain entity that...
I realized I didn't explain why I was asking the questions. I'm interested in how you go about using mocking within the domain as a tool to help you drive...
... Which kind of logic? Pure domain logic? or service logic like persistence or participating in a transaction? The former belongs, and the latter does not. ...
... Pure domain logic, our domain model doesn't participate in transactions or persistence or anything else like that. In fact our domain layer really only...
... What is in the first cut of MyDbClass? If it provides some kind of external service that finds things for me (described in the domain of the application),...
Let's say it's just a simple UserDaoAdo.cs class, because I need a FindUser(). I'm just wondering if you'd create the UserDao interface (kind of by default)...
Hi all, I'm playing with Rhino Mocks and have some questions 1. When I call on my mocked view: Expect.Call(_viewMock.FirstName).Return("damien"); What's...
You need to distinguish between constraints, which check how an object is called, and actions, which return a value or throw an exception to support the rest...
My colleague Nat has a horror of classes called *Repository, *Dao, etc. because that sort of name is about implementation not the domain. In this case, an...
Hi Vishal, Please take a look at the following post that explains a similar problem to what you are experiencing, and Mocking technique I use when dealing with...
With an interface. Sent from my iPhone ... Your rules about when to use interfaces in the domain seem sensible to me, though we don't even put interfaces on...
... entities/value ... Ta for replying and I agree. I actually follow basically the testing approach described in the article for entities too, rarely mocking ...
... A system comprises many domains. E.g. domains of business logic, communication, persistence, etc. Classes in any domain either represent values or objects...