Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpringBoot Test #300

Open
uniquejava opened this issue Apr 17, 2020 · 1 comment
Open

SpringBoot Test #300

uniquejava opened this issue Apr 17, 2020 · 1 comment

Comments

@uniquejava
Copy link
Owner

uniquejava commented Apr 17, 2020

Integration Tests with @SpringBootTest: https://reflectoring.io/spring-boot-test/

junit4测试 mockmvc + mockito
junit5测试 mockmvc + mockito
https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-testing

junit4测试spring security oauth2
https://docs.spring.io/spring-security/site/docs/current/reference/html5/#test

junit5测试spring security oauth2

我碰到的问题 MockBean始终为null.

解决方案在这。 两种
https://github.com/spring-projects/spring-boot/issues/7689#issuecomment-615574514

原因在这: https://github.com/spring-projects/spring-boot/issues/9609

我都加了comment :joy:

是继承了 AbstractTransactionalJUnit4SpringContextTests 的锅

加一个Listener就好了

GlobalExceptionTranslator (DB Column长度不够时 e.getMessage暴露的信息太多?)

@uniquejava
Copy link
Owner Author

mockito 连续相同方法调用返回不同值

    when(mockFoo.someMethod(anyString(), anyInt()))
            .thenReturn(obj1)
            .thenReturn(obj2)

见: How to tell a Mockito mock object to return something different the next time it is called?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant