Grails 2.3.8应用程序集成测试失败

时间:2015-04-23 15:16:16

标签: grails

我开始编写一个简单的grails应用程序。到目前为止,我只有一些域类,没有其他文物。昨天我运行了我唯一的集成测试并且它通过了。今天当我运行它时,我得到了这个输出:

2015-04-23 11:07:37,000 [main] ERROR hbm2ddl.SchemaUpdate  - Unsuccessful: create table or
der (id bigint generated by default as identity, version bigint not null, customer_id bigi
nt not null, date_created timestamp not null, total float not null, primary key (id))
Error |
2015-04-23 11:07:37,002 [main] ERROR hbm2ddl.SchemaUpdate  - Syntax error in SQL statement
 "CREATE TABLE ORDER[*] (ID BIGINT GENERATED BY DEFAULT AS IDENTITY, VERSION BIGINT NOT NU
LL, CUSTOMER_ID BIGINT NOT NULL, DATE_CREATED TIMESTAMP NOT NULL, TOTAL FLOAT NOT NULL, PR
IMARY KEY (ID)) "; expected "identifier"; SQL statement:
create table order (id bigint generated by default as identity, version bigint not null, c
ustomer_id bigint not null, date_created timestamp not null, total float not null, primary
 key (id)) [42001-173]
Error |
2015-04-23 11:07:37,004 [main] ERROR hbm2ddl.SchemaUpdate  - Unsuccessful: alter table ord
er add constraint FK651874E6A961CB1 foreign key (customer_id) references customer
Error |
2015-04-23 11:07:37,004 [main] ERROR hbm2ddl.SchemaUpdate  - Syntax error in SQL statement
 "ALTER TABLE ORDER[*] ADD CONSTRAINT FK651874E6A961CB1 FOREIGN KEY (CUSTOMER_ID) REFERENC
ES CUSTOMER "; expected "identifier"; SQL statement:
alter table order add constraint FK651874E6A961CB1 foreign key (customer_id) references cu
stomer [42001-173]
Error |
2015-04-23 11:07:37,005 [main] ERROR hbm2ddl.SchemaUpdate  - Unsuccessful: alter table ord
er_item add constraint FK2D110D6455275AA3 foreign key (order_id) references order
Error |
2015-04-23 11:07:37,005 [main] ERROR hbm2ddl.SchemaUpdate  - Syntax error in SQL statement
 "ALTER TABLE ORDER_ITEM ADD CONSTRAINT FK2D110D6455275AA3 FOREIGN KEY (ORDER_ID) REFERENC
ES ORDER[*] "; expected "identifier"; SQL statement:
alter table order_item add constraint FK2D110D6455275AA3 foreign key (order_id) references
 order [42001-173]
.......
|Compiling 1 source files
..
|Tests PASSED - view reports in C:\Users

当我打开HTML测试结果页面时,它表示没有执行任何测试。我甚至试过grails clean-all。此时我的项目刚刚开始,所以我可以轻松创建一个新的应用程序并将我的代码复制到那个,但我很想知道这个应用程序有什么问题。昨天这个测试运行良好并通过,我所做的就是关闭我的IDE并在今天再次启动它。我甚至关闭了ide并尝试从命令提示符运行测试,但结果相同。

如果有人想查看代码,那就是here

1 个答案:

答案 0 :(得分:2)

dbCreate = "update"修改为dbCreate = "create-drop"测试环境中的DataSource.groovy(正好here)应解决此问题。

基本上它会在测试之间重新创建db,这在测试期间会更清晰。