chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Hello,

I am new to both this and TDD and still struggling a little bit. The biggest problem I have is that I have a bunch of scenarios that I want to TDD. All of them are specified from a customer's point of view, so the natural thing is to start TDD top-down. That means that when I need to mock the underlying services in a domain object, this has not yet been created. How do I mock classes and objects that are not yet created?

What is the best practice TDD when using TypeMock?


Thanks,

Morten
asked by petteroe (3k points)

1 Answer

0 votes
Hi Morten

Good question there are few possibilities here.
It depends on what do you have:

Do you know how the API of the underlying services will look like?
In that case you can write the skeleton code for it just to allow the tests
that call it pass compilation.
(NotImplementedException is your friend here :wink:)
Than in the tests use TypeMock to mock services methods.

If you don't know how the API is going to look like you can use TypeMock
for prototyping the underlying services. Write the interfaces or abstract class code and than use MockObject to create
instances that can be used in your tests.
You can than start slowly build from there the services.
I think this can give you a good 'feel' of how the API should look like from the customer point of view.

Please post here more details or code examples so we can help you
more specifically.
answered by ohad (35.4k points)
...