Testifi
Testifi takes Apifi to the next level by autogenerating integration tests for all autogenerated GraphQL resolvers. It integrates with Mockeri to combine intelligent data mocking with all integration tests.
Overview
The purpose of this library is to provide a rudimentary level of integration testing against APIs created with Apifi. It does so by using the Mockeri library to generate sufficient mock data to perform the necessary testing, and then executing CRUD operations against each resolver in the API schema. The objective is to ensure that the API basically works. Obviously, this tool is no replacement for whichever edge-case testing may be necessary in any given use case. That is up to the developer. However, simple flaws in datamodel design, underlying infrastructure and configuration flaws, etc. are detectable using these autogenerated tests.
A few friendly suggestions
- Please aquaint yourself with both Apifi and Mockeri prior to using this library.
- Use this tool with several fine grains of salt ;)
Installation
Testifi can be installed using jitpack, as follows:
Maven
Testifi is available on maven central:
<dependency>
<groupId>org.sindaryn</groupId>
<artifactId>testifi</artifactId>
<version>0.0.1</version>
</dependency>
Requirements
- The main class must be annotated either with
@SpringBootApplication
, or@MainClass
. - All entities must have a public
getId()
method.
Activation
As previously stated, this library relies on Mockeri for generating data to test against. Therefore, in order to signal to Mockeris' DatabasePopulator
bean to go ahead and populate the database with mock data, the environment varaible DUMMY_POPULATE=true
must be exported, prior to running or debugging the project.
Detailed instructions
Plug, play & debug.
Known Issues
The getAsEmbeddedCollection
test can be unreliable when evaluating self referencing many to many relationships.
That's all for now, happy coding!
License
Apache 2.0