开发者

Play! Framework loading yaml from test sub package

开发者 https://www.devze.com 2023-04-01 15:03 出处:网络
I have a yaml file loaded by BasicTest.java in the t开发者_如何学运维est package, this creates the db data as expected in the h2 in memory db.When I move the BasicTest.java into a sub package, e.g. te

I have a yaml file loaded by BasicTest.java in the t开发者_如何学运维est package, this creates the db data as expected in the h2 in memory db. When I move the BasicTest.java into a sub package, e.g. test.unit, it does not work. The yaml file is found, but the data is not created. What needs to change to fix this?

My test setup is shown below.

@Before
public void setUp() {
    Fixtures.deleteAllModels();
    Fixtures.loadModels("data.yml");
}


Try to add path to your "yml" to play framework internal PATH before you try to load it. Example(path to file is relative to application path):

VirtualFile appRoot = VirtualFile.open(Play.applicationPath);
Play.javaPath.add(0, appRoot.child("test/sub/packages/data.yml"));
0

精彩评论

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