开发者

Play framework testing and access to session object when using MongoDB

In play framework application.conf there are lines:

%test.db.url=jdbc:h2:mem:play;MODE=MYSQL;LOCK_MODE=0
%test.jpa.ddl=create

But I am using MongoDB with Morphia. How do I change开发者_运维知识库 above settings for testing? Note that I am not using play framework morphia module.

From technical point of view, each unit test would have its own in memory instance of mongodb test database. How to make that happen?

Also when I use session object in test code both in functional and unit tests, I get compile error value session not found. How to access session in test code?


There isn't a way to modify those settings to create an "in memory instance of mongodb". If you want each unit test to have a clean copy of the database, you'll have to setup & teardown a new copy of your database in mongodb for each test.

You can grab the session cookie directly in your functional tests using Scope.Session.current().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜