write sample Test-class to usher how create test in spring.
I use BDD design for test. the test contain mockTest, standaloneTest, restTest and ...
- control test section
- standalone test (how test specific class without create other class and context)
- use applicationContext for test (how test specific class with spring applicationContext)
- MockTest (how test specific class with springMockMvc)
- RestTest (how run whole application and use restTemplate for test)
- repository test section
- service test section
- Integration Test section
- Create Test for all method of ProductController to test whole project
- use H2 as TestDataBase that divided production from test environment
- Define TestH2Repository as jpaRepo for test
How to use:
in this project use postgresql for production and H2 for test, so if you want use it code,
for production mode : Run postgres and create 'test' database, then write your config in application.yml file
at test section just run test and create db and other thing by jpa and H2, just run any test as you want.
NOTE: This project is being developed