1. 2
  1.  

  2. 3

    So my unit tests assume I have Docker installed and running? Err…

    1. 1

      Yup, that would be the idea, I’m afraid …

    2. 1

      Why mock if you can have the real thing? Containers are here to help you testing the real thing across environments.

      Because mocking is WAY faster. It totally reminds me this talk https://www.youtube.com/watch?v=bNn6M2vqxHE on Ruby on Rails testing.

      1. 1

        Yes, I mentioned this as a drawback.

        1. 1

          I don’t think it’s fair to call this a “characteristic” with “a little overhead”.

          Two reasons why it might not be realistic:

          • microservices (having +100 docker images to fetch/launch/.. each time you want to test things)
          • it’s damn slow. When I test I expect a really quick feedback. A mocked test is in ms, a container one is in seconds… This multiplied by hundred of tests, is a huge load on CI servers and something impossible on my laptop…

          I like the idea of not having to mock, but alas, I’ll keep doing it.

          1. 1

            I think you’re raising a good point. Will update the post with this concern, or, if you prefer and don’t mind you comment on the Medium post yourself? In any case I’d like to thank you and credit you with it …

        2. 1

          Mocking also allows me to test in isolation, which is the whole point of a unit test- I want to test a single, specific unit, that way if it doesn’t behave as expected, I know why (or at least, I’ve narrowed it down). Testing interactions with etcd with a real instance of etcd introduces all sorts of complexities that make it difficult to reason about the unit test.

          Integration tests, sure, whatever, have at. The closer your integration tests get to a real-world environment, the better.

          1. 1

            Hmmm. OK, here’s a question: does the fact that in my example the unit is all about directly reading from and writing to etcd change anything concerning your statement? I suppose I’m not sure I understand where you draw the line …

            1. 1

              I mean, if you’re crossing a boundary, it’s not a unit. Modularize better, because you’re apparently not doing it.