-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Support new default value of spring boot 2.1 of spring.main.allow-bean-definition-overriding #17
Comments
I asked about a different annotation and they added information about it here: |
Hi. I'll take a look into this but cannot promise when it will be fixed. To be honest, I've not used this library for some time now and I'm not working with spring-boot nor springboot2 at that moment, therefore, I'm not actively using this library now. PR will be always welcomed :) I've just created a branch on which I plan to work on this and added sample which fails the build: |
Hi, I am not sure we would use this library, but if/when I have a free moment I am happy to look at it :) |
@huehnerlady You can give it a try. It's been deployed to maven snapshots repo. I'll release it in a day or two after I double check if everything is working as supposed. You can configure use snapshots using this instruction: https://github.com/pchudzik/springmock#snapshots |
I've just released it you can give it a try:
or
|
Hi, Sorry that I didn't answer earlier.
TestApplication:
When I run the test, I receive
do you have any idea what I am doing wrong? spring version: 5.1.2.RELEASE Many thanks |
Hi. I'm not sure what you want to achieve. You are defining class MyService (which is not even static so probably will not be picked up by spring) inside test class and want to mock it? It is not real life example is it? Please take a look at: It's a bit more complex and shows more examples of what can you do but in some way is very similar. It mocks behaviour of some service (AddOneTranslator), verifies interaction with other (spied TwoRepository) and shows mixed spring-mock with native spring mocks (LogService) You can also find some more description in my blogpost |
Well basically I had the problem in our system and so I tried to make a small example which leads up to that problem. I have a Service (marked with the annotation @Servioce) and I have a test. in that test I want to mock the Service. This happens usually our Controller Integration tests where you tests errors etc. of the endpoint and one scenario would be that the service is called with the correct data. But when I use the We do not have Mockito at all in our dependencies as we use spock for everything. |
Maybe you can implement this example inside springmock samples. Just clone the repo (git@github.com:pchudzik/springmock.git) there is project already configured with springbok2 in folder samples/spock-springboot2 you can import it in idea or eclipse and create classes that reflect how you are working with spring and springmock and the problem you have (from what you are saying it doesn't look like a lot of work and it will be much easier for me to debug it and see what's going on). Once you'll reproduce issue you have just create pull request for springmock (samples folder is also tested) and from there I'll take over and see what needs to be fixed. If you could reproduce the issue you are having in there I'll be happy to help and fix any bug. From the stacktrace you have pasted I will not be able to help you out there is just not enough information for me to figure out what might be wrong. |
Hi, that sounds fair, so I will see when I can implement it :) |
I tried to reproduce it in your project, but could not achieve it. So for your project it seems to work. But thank you very much for your help. |
Sure no problem. You can also tray and provide more detailed stack trace and exact dependencies versions you are using? Sample project is simple so it might not necessary reflect real life case. Maybe there is something related to particular version of libraries you are using (for example cglib) |
Aaah good point, |
Hi, while I was removing the data I showed it to a colleague, and he found out that your version of bytebuddy is not compatible with groovy 2.5.5 which we use in our systems. Many thanks for your support :) |
So for now you are good to go with just overriding bytebuddy version :) btw. If you are using Spock>=1.2 there is@SpringBean and @SpringSpy implemented natively as a part of spock-spring module. |
oh wow thank you so much, I actually did not know about this :) |
Hi,
will you add support of the fact that
spring.main.allow-bean-definition-overriding
is now defaulted to false and therefore your annotation ends up in aorg.springframework.beans.factory.support.BeanDefinitionOverrideException
?The text was updated successfully, but these errors were encountered: