spray / twirl

The Play framework Scala template engine, stand-alone and packaged as an SBT plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using twirl in integration tests

talkol opened this issue · comments

I'm trying to use twirl as part of my integration tests.

My integration tests have an HTTP simplicator that mimics a real world service. To implement this simplicator in the tests, I'm using spray-can embedded HTTP server which needs to spit out responses based on twirl templates.

My tests are located at /src/it/scala so naturally I want to place these twirl templates inside /src/it/twirl. This doesn't work since the twirl compiler ignores this directory.

If I place the twirl templates in /src/main/twirl, everything works fine - but I'm trying to avoid this because I don't want these templates to clutter the production package (the templates only come into play in the tests so they should only compile inside when the tests are run).

How can I tell the twirl compiler to look for templates in the new directory?

That's currently not supported. As a workaround you can look at the keys defined in https://github.com/spray/twirl/blob/master/sbt-twirl/src/main/scala/twirl/sbt/TwirlPlugin.scala and CnP and redefine all for the integration scope, i.e. copy all those settings that have in Compile and replace it with in IntegrationTest.