Open uniquejava opened 4 years ago
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暴露的信息太多?)
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?
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.
GlobalExceptionTranslator (DB Column长度不够时 e.getMessage暴露的信息太多?)