I'm trying to adopt Swagger in REST API development (Spring Boot web application). API documenting process and code generation based on swagger spec works good, and now I've faced a problem writing integration tests using assertj-swagger and SpringFox libraries.
A few little words about these libraries. Springfox works by examining an application, once, at runtime to infer API semantics based on Spring configurations, class structure and various compile time java annotations. The swagger-assertj test library should compare a contract-first Swagger YAML file with a code-first Swagger JSON generated by SpringFox. For Consumer Driven Contract tests, assertj-swagger fails a test if it finds missing resources, methods, models, or properties in the implementation which are required by the consumer specification.
My test looks like (test code is taken from GitHub example):
@RunWith(SpringRunner.class)
@SpringBootTest
public class AssertJSwaggerConsumerDrivenTest {
@Test
public void validateThatImplementationSatisfiesConsumerSpecification() {
String designFirstSwagger = AssertJSwaggerConsumerDrivenTest.class.getResource("/swagger.yaml").getPath();
SwaggerAssertions.assertThat("http://localhost:8080/v2/api-docs")
.satisfiesContract(designFirstSwagger);
}
}
The problem is that this test is executed for a long time and seems to get stuck cause I don't see any log output after this line:
INFO c.s.e.AssertJSwaggerConsumerDrivenTest : Started AssertJSwaggerConsumerDrivenTest in 24.03 seconds (JVM running for 26.774)
- I'm sure that SpringFox is working, cause I see JSON after opening
GET http://localhost:8080/v2/api-docs
in my browser. - I have no compile-time or build-time errors when running test, cause Maven resolved dependencies and Spring Boot context is initialized successfully.
Is there anybody experienced in using assertj-swagger cause it looks like I'm doing something wrong?