开发者

Create Play! Framework tag for selenium tests only

I'm writing a selenium test using the Play! Framework and som开发者_如何学Pythone tests have common bits. I want to pull those common bits out into a Play! tag. In production code, tags would live under app/views/tags. However, where would a tag live to be only seen by test templates?

I tried putting my tag under test/tags and test/views/tags, but both ways resulted in the error:

The template tags/Login.html or tags/Login.tag does not exist.

If I put the tag under app/views/tags it works fine. But obviously this tag is for testing purposes only.


Tags must be under app/views/tags (any subfolder of it), otherwise Play won't get them. You canc reate this path: app/views/tags/testing and put in there the test-only tags, so developers know not to use them.

To use a tag Demo in that folder use:

#{testing.Demo /}

If you want to disable them in production (for extra safety) check this api. Add to your tag something like:

#{if play.mode.isDev()}
     tag code
#{/if}


As far as I know Tags must be under app/views/tags or any subfolder. How ever I'm sure you can define Tags in a module and import this only in test mode. A little bit complicated but clean.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜