Creating integration tests in a monolithic SpringBoot application

前端 未结 2 1465
情话喂你
情话喂你 2021-01-24 00:07

I was asked to create an integration test for a service within a very large SpringBoot project yielding dozens of implemented services. When the application is executed all of t

2条回答
  •  孤城傲影
    2021-01-24 00:24

    If you have to create spring integrations tests you have to : - invoke spring Context by using annotation on test class - for instance : @RunWith(SpringJUnit4ClassRunner.class) - use @MockBean or @SpyBean annotation on services that you are not going to test but they are part of testing methods/class - use @Autowired annotation on class that you are going to test. To verify results you can use Junit4 or Junit5 asserts and for verifying behavior you can use Mockito

提交回复
热议问题