Skip to content

Instantly share code, notes, and snippets.

@mengjiann
Created October 2, 2019 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mengjiann/0fb358def60fca2194394333a6df6659 to your computer and use it in GitHub Desktop.
Save mengjiann/0fb358def60fca2194394333a6df6659 to your computer and use it in GitHub Desktop.
Springboot - WebMvcTest
@RunWith(SpringRunner.class)
@WebMvcTest(EntrySubmitRestController.class)
@ContextConfiguration(classes = EntrySubmitRestControllerTest.ContextConfiguration.class)
public class EntrySubmitRestControllerTest {
@TestConfiguration
static class ContextConfiguration {
@Bean
@Qualifier("entrySubmitDueDate")
public LocalDate getEntrySubmitDueDate(){
return LocalDate.now().plusDays(1);
}
}
@Autowired
@Qualifier("entrySubmitDueDate")
private LocalDate entrySubmitDueDate;
}
@mengjiann
Copy link
Author

Provide beans for WebMvcTest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment