digiarnie
digiarnie

Reputation: 23415

Create Play! Framework tag for selenium tests only

I'm writing a selenium test using the Play! Framework and some 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.

Upvotes: 2

Views: 672

Answers (2)

Pere Villega
Pere Villega

Reputation: 16439

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}

Upvotes: 2

niels
niels

Reputation: 7309

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.

Upvotes: 0

Related Questions