One option for running my tests in my Play! application is by executing the command play auto-test.
One of the ways Play seems to identify tests to run is to find all test classes with the super class play.test.UnitTest (or another Play equivalent). Having a test class extend UnitTest seems to come with some overhead as shown by this bit of stuff spat out in the console:
INFO info, Starting C:\projects\testapp\.
WARN warn, Declaring modules in application.conf is deprecated. Use dependencies.yml instead (module.secure)
INFO info, Module secure is available (C:\play-1.2.1\modules\secure)
INFO info, Module spring is available (C:\projects\testapp\.\modules\spring-1.0.1)
WARN warn, Actually play.tmp is set to null. Set it to play.tmp=none
WARN warn, You're running Play! in DEV mode
INFO info, Connected to jdbc:h2:mem:play;MODE=MYSQL;LOCK_MODE=0
INFO info, Application 'Test App' is now started !
Obviously having a Play environment for tests that requires such a setup is useful, however, if I have a test class that tests production code that executes logic that does not require a Play environment I don't want to have to extend UnitTest so that I can avoid the overhead of starting up a Play environment.
If I have a test class that does not extend UnitTest then it does not get executed by the command play auto-test. Is there a way to get the play auto-test command to execute all tests regardless of whether I extend Play's UnitTest?
Edit: Someone has actually raised a ticket for this very issue
the short answer: no. A tad longer answer: no unless you change code in the framework. The autotest is an Ant task that sets the server and triggers the testing, but it's not using the ant task, so it won't detect (by default) your 'normal' unit tests.
You have two options: either you add an extra task to the Ant file of Play to run unit tests via the task (you will need to include the relevant jars too) or you edit the code used to launch the Play test environment.
Both imply changing the framework to a certain level. Although giving that you are using Play, I wonder why you should not have all your tests follow the Play pattern...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With