Skip to content

Commit

Permalink
Dev fix3 add how to init data in database h2 tables (#224)
Browse files Browse the repository at this point in the history
* Update how-to-write-unit-test-code.md
  • Loading branch information
husofskyzy authored Apr 8, 2022
1 parent 7ce5042 commit 633972e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions community/how-to-write-unit-test-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,12 @@ Use H2 database, application. In the configuration file In properties, you need
```properties
#h2 database configuration
spring.datasource.driver-class-name=org.h2.Driver
# Script to connect and initialize the table
spring.datasource.url=jdbc:h2:mem:test;MODE=MySQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=true;INIT=runscript from 'classpath:create.sql'
# Script to connect database
spring.datasource.url=jdbc:h2:mem:test;MODE=MySQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=true
#Script to initialize database tables
spring.datasource.schema=classpath:create.sql
#Script to initialize data for database tables
spring.datasource.data=classpath:data.sql
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.hikari.connection-test-query=select 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,12 @@ Assertions.assertThrows方法,用来测试Executable实例执行execute方法
```properties
#h2数据库配置
spring.datasource.driver-class-name=org.h2.Driver
#连接以及初始化表的脚本
spring.datasource.url=jdbc:h2:mem:test;MODE=MySQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=true;INIT=runscript from 'classpath:create.sql'
#连接数据库
spring.datasource.url=jdbc:h2:mem:test;MODE=MySQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=true
#初始化数据库表的脚本
spring.datasource.schema=classpath:create.sql
#初始化数据库表中的数据的脚本
spring.datasource.data=classpath:data.sql
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.hikari.connection-test-query=select 1
Expand Down

0 comments on commit 633972e

Please sign in to comment.