How correctly imitate dependencies?

This is continuous of my previous post about why we should imitate our dependencies. I did it not long ago. I though about how do it properly and when I can say that it is correct.

Start from test and real dependencies

I am starting from the tests. I wrote the simple tests which, I though, are correct. That was my learned about dependencies. I had the good situation that I had some prepared tests before. During the writing test I got a knowledge. A lot of time, I verified what the system return. After it, I got the full automated tests for my dependency. Now, I am sure that dependency works like I think. Like my test use it. I think this is a very good advantage.

Extract the interface for communicating

The implementation to communicate is implemented and tested. Our test, if you implement it like functionality test, not code test, should show us, how we want to use our dependency. We know what parameters we use, what methods. We know what we want. That is a place where we must extract the interface, which doesn't change our test. We should only change created object to injected interface (on contractor or using a framework). If you do it, check if your tests still pass. Ok, we can go to the next step.

Implement the interface so that it passes the tests

That should be easy, we know what we want. That is the same like we need to implement every day. We have a requirement, we need to pass it. We have automatically tested it, because we have prepared test. This is why I prefer to do previous steps. Now, we easier implement our code. Our imitate. I tried previous to implement the similar imitate without test. I had a lot of bugs on that, so finally I drop that code. Now, I am sure that I have a working imitate.

This is all

I thought this is very easy. I spend only 2 days to implement it. Of course, this is dependent on complexity of use dependency, but using my way of working I do it faster than I did before. This is why I want to show you my way, which I will use (if I will not find new and better).

Comments

  1. Wow, it’s very helpful blog for comments. Will try to follow all these stuff!
    Keep upgrading.

    Java Training in Chennai

    Java Course in Chennai

    ReplyDelete
  2. You just made my day by writing on how can we enable Page Link in Oracle Apps R12. Thumbs up for this brilliant information. Have a good day. Dissertation Writing Services

    ReplyDelete
  3. Informative content,thanks for sharing...waiting for next update.
    IBM Training in Chennai
    IBM Course in Chennai

    ReplyDelete

Post a Comment

Popular posts from this blog

Why TDD is bad practice?

Software development using Angular 5 with Spring Boot