我有一个正在尝试通过Spring MVC Test测试的RestController。它包含以下ModelAttribute: public User authUser(@AuthenticationPrincipal).setAttribute(ConstantsHome.USEROBJECT_KEY, user); }
当我对这个RestController运行测试</e
我想测试一个控制器,它使用@ModelAttribute作为它的一个方法参数。正在使用@RequestParam的@ModelAttribute方法public ExampleEntity getExampleEntitygetSuccessView(exampleEntity) : VIEW_NAME;}@WebAppConfiguration
public class ExampleC
我读到,当使用@Mock时,它应该与@RunWith(MockitoJUnitRunner.class)一起使用,而对于@MockBean,它应该与@RunWith(SpringRunner.class然而,对于@Mock,我看到MockitoJunitRunner或SpringRunner都可以互换使用。我很困惑为什么SpringRunner也能在这种情况下工作?SpringRunner.class) is used @InjectMocks
private ServiceA serviceA;