I am using springboot and H2 database for test cases.
I have multiple test classes each annotated with @SpringBootTest. Each class has multiple test methods annotated with @Test
My doubt is, will h2 database be cleared
If case1 is true, then need to load the data to database in the @Before method which will be executed before each test method?
If case2 is true, then need to load the data to db in the @BeforeClass method which will be executed before each class execution.
If case3 is true, then if i load all the data to db in a test case, how to make it run first before all other test cases run.
What is the appropriate place to load the data to database?
Thanks in advance.
database-rider could be useful for initializing your H2 database with data before each test case. See https://github.com/database-rider/database-rider
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.