This is a demo project to show how JFixtures works on practice
https://github.com/vkorobkov/jfixtures
The main goal of this demo project to show how we can use JFixtures for populating relational databases with yml-based test data and test our services. There are some simple steps for using:
- add maven dependency of JFixtures to your
pom.xml
file:
<dependency>
<groupId>com.github.vkorobkov</groupId>
<artifactId>jfixtures</artifactId>
<version>${jfixtures.version}</version>
<scope>test</scope>
</dependency>
- put a yaml based test data to
resources
folder - convert the test data using JFixtures to a string or a file and execute generated SQL query:
import com.github.vkorobkov.jfixtures.JFixtures;
Path fixturesPath = Paths.get("src/test/resources/yaml/user")
String sql = JFixtures
.withConfig(fixturesPath.resolve('.conf.yml'))
.load(fixturesPath)
.compile()
.toSql99()
.toString()
jdbcTemplate.execute(sql)
- That's all! Now you can use it anywhere you need in the project.
Please see test examples here:
CommentService/src/test/groovy/com/github/rodionovsasha/commentservice/services
mvn clean install
or using wrapper
./mvnw clean install
http://localhost:8080/v1/api
mvn spring-boot:run
or using wrapper
./mvnw spring-boot:run
or simply run the application in your IDE using public static void main method.