Unit Testing - Isolation Testing

I have a set with several layers:

  • Web site
  • Application / Service
  • Domain (contains objects)
  • Persistence (contains repositories)

I am testing the persistence layer in isolation OK, using the data created in memory from the stub object.

Now I'm thinking of testing my layer on the site. I know that I have to test it in isolation, that Im-thinking means creating a stub for the Application layer object that it uses, but for this stub you will need your own data set in memory duplicated in the stub at the persistence level, and I don't want to do this duplicate it and manage it.

So my question is, should the subject always work with stub objects from the layer below to be isolated, and usually they have their own data set? Or is it suitable for my tested web method to call a lightweight object at the application level that invokes the Persistence level with stub data?

Thank you for your help. This seems like the last bit of a puzzle to me ...

+3
source share
3 answers

. , , . , .

, , ,

+5

- , Persistence ?

, a unit test - , ? - . , , . unit test - , mock/stub .

+1

Setting up test data can be a tedious task. If you use DotNet, you can use the NBuilder library to generate test data very quickly and easily. It supports a good free interface. You can read about it here .

0
source

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


All Articles