How do you balance the design of Framework / API and TDD

We are creating a framework that will be used by other developers, and now we use many TDD methods. We have interfaces everywhere and have well-written unit tests that mock interfaces.

However, we have now reached the point where some of the properties / methods of the input classes must be internal and not visible to our infrastructure users (for example, the object id). The problem is that we cannot put these fields / methods on the interface, because the interface does not describe accessibility.

We could:

  • Still use the interfaces and increase the speed in the first line of the method, but this seems to have exceeded the goals of the interfaces.
  • Using classes as input parameters is a violation of the TDD rule that everything should be an interface
  • Provide a different layer that does some translation between public interfaces and internal interfaces.

Is there an existing model / approach to solve this problem? What do TDD people say?

+3
source share
3 answers

You should be able to replicate these internal methods in your mock objects. And name them in the same way as a real object calls them. Then you focus your unit test on a public method that relies on this private method that you need to test. If these internal methods call other objects or do a lot of work, you may need to reorganize your design.

Good luck.

+2
source

-, TDD, , . , TDDer. . http://martinfowler.com/articles/mocksArentStubs.html

-, . "" , @Published, API. , Eclipse . , .

+4

, , . stackoverflow. , .

[1l

0

Source: https://habr.com/ru/post/1698853/


All Articles