Reputation: 205
As per official document How to Debug, I need to add following to the property file to enable logging
logging.level.org.apache.http.wire=DEBUG
logging.level.com.github.tomakehurst.wiremock=DEBUG
But, I don't see any logs visible on the console when request sent to wiremock server. I'm getting 500 Internal Server Error
only specific platform. So, to troubleshoot I'm trying to intercept activity when request reached to wiremock server.
In my pom file
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-contract-stub-runner</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
<scope>test</scope>
</dependency>
I also tried adding logback-test.xml
file with following content. But, this is not logging anything as well.
<logger name="com.github.tomakehurst.wiremock" level="DEBUG"/>
<logger name="wiremock.org" level="DEBUG"/>
<logger name="WireMock" level="DEBUG"/>
<logger name="/" level="DEBUG"/>
My test class
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
classes = MyApplication.class)
@AutoConfigureMockMvc
@TestPropertySource(
locations = "/application-integration-test.properties"
)
@AutoConfigureWireMock(port = 0)
@AutoConfigureWebTestClient(timeout = "100000")
public class MyApplicationTest {
private WebTestClient client;
@LocalServerPort
private int port;
@Before
public void setUp() throws Exception {
client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
}
/// Test code
}
Anyone suggest what am missing ?
Upvotes: 3
Views: 3454
Reputation: 457
If you are using WireMock via Spring annotation @AutoConfigureWireMock
, best way to see WireMock (verbose) logs in test console output should be to add this bean in your test class:
@TestConfiguration
static class WireMockTestConfiguration {
@Bean
WireMockConfigurationCustomizer optionsCustomizer() {
return config -> config.notifier(new ConsoleNotifier(true));
}
}
You may use @Import
to add WireMockTestConfiguration
to Spring context.
Upvotes: 7