I am trying to create a H2 database in my Spring Boot project, when I run a cucumber test.
I have this in my application.yml:
booking:
datasource:
username: sa
password:
url: jdbc:h2:mem:bookingdb;DATABASE_TO_UPPER=false;DB_CLOSE_DELAY=-1
driver-class-name: org.h2.Driver
My cucumber test is stored in my Cucumber package in src/acceptTest/java folder. And the below data.sql file is stored in src/acceptTest/resources folder:
CREATE TABLE tlink (
link_id int,
ext_id varchar(255),
address_id varchar(255),
client_id varchar(255),
instance varchar(255),
source varchar(255),
timestamp datetime2
);
INSERT INTO TLINK(link_id, ext_id, address_id, client_id, instance, source, timestamp) VALUES(13582,'0000059811','3037260','0000059811','1','1', '2018-08-22 15:13:34');
When I run the runner class, the tests are being executed, but the database isn't being created.
Below are some of the logs:
Caused by: org.hibernate.exception.SQLGrammarException: could not prepare statement
Caused by: org.h2.jdbc.JdbcSQLException: Table "tclientlink" not found; SQL statement:
The CREATE statement in data.sql does not seem to be getting picked up in my code. Why could this be happening?