Changing my custom dependencies with Spring

Is it possible to declare mocks using some mocking structure for my own classes declaratively using Spring? I know that Spring has some standard layouts, but I also want to declare my own classes.

Just to verify that I'm not mistaken: the idea is to have a couple of JUnit and Spring tests for each integration test I want to do, mocking everything except the specific aspect of integration I '(let's say I had a dependency on two different data services, checking one at a time) and minimizing the number of repeated Java code defining mocks.

+3
source share
3 answers

context.xml, XML beans. , , .

+1

- .

, , ,

spring, , , . , "" , .

, ...

GOOS. .

http://www.growing-object-oriented-software.com/

0

beans, , , @Primary.

You must annotate a special class for tests using @Primary - then it will "override" the real class. “But use it only if you want to do it for all tests.”

0
source

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


All Articles