alfredodiaz / therore-spring-mockito Goto Github PK
View Code? Open in Web Editor NEWThis project forked from knes1/springmockedtests
Annotations for facilitating integration tests with Spring and Mockito
License: MIT License
This project forked from knes1/springmockedtests
Annotations for facilitating integration tests with Spring and Mockito
License: MIT License
Hi Alfredo
I have come across your repo and the solution in this repo https://github.com/hobo05/mockitobeans in my attempt to achieve some easy mocking in my Spring integration tests.
All though yours is a bit different from the MockitoBeans, I still wanted to post my question to you here.
Using the MockitoBeans approach I have two integration test classes associated with a Spring Boot application.
Each of the test classes have the @MockedBeans but each with different mocked classes.
For instance TestClassA has a BeanA which it wants mocked and TestClassB has a BeanB which it wants mocked.
However, when I run either test, both @MockedBeans occurrences are picked up by the registrator and thus both mocks are created and the actual beans are not available in either test.
I would like to be able to scope the effect of the @MockedBean so that it only registers what is on the test class being executed.
Would that be possible with your solution?
If not, I would very much appreciate any advice you might have as to how it might be possible inside the Bean registrator class to get information about the current JUnit test being executed.
My idea is that if JUnit can provide the name of the test about to be run, then it would be easy to simply just register mocks for that given class and ignore the rest of the mock enabled test classes.
My assumption here is that when a full mvn test run is executed, the mocks are loaded for each test so that this strategy would also work when running all tests and not just a single one.
@hobo05 had an idea about filtering away other test classes which have the @MockedBean in the ComponentScan. That approach might work, but I would prefer a solution which is least intrusive to the test code - meaning that fewer lines of code are to prefer.
Again, thank you for your time.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.