Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
* main spring boot integration test with integration test profile
*/
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("INTEGRATION_TEST")
@ContextConfiguration
public class CucumberRoot {
@Autowired
protected TestRestTemplate template;
@Before
public void before() {
// demo to show how to add custom header Globally for the http request in spring test template , like user header
template.getRestTemplate().setInterceptors(Collections.singletonList((request, body, execution) -> {
request.getHeaders()
.add("userHeader", "user");
return execution.execute(request, body);
}));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment