mpetitdant
mpetitdant

Reputation: 75

Integration tests with Play Framework, without use of fixtures

I'm trying to set up automated integration tests on a new project. The used stack is :
Play! Framework
SOAP Web services
Relational DB

Since I want to write integration tests, I need to manage what data is in my database, this is usually done with Fixtures integrated in play framework. But since I don't use the Play framework's Model, this is not possible.
In addition, if you have tips about the test data set maintenance ?

Additionally, if I'm doing integration tests of all my stack, I should (ideally) do them outside the Play project, then I'll loose the benefits of play's testing tools. Should I keep them in the Play project ?

If I create a new projet just for these tests, have you any advices on the tool to use : selenium, htmlunit, ...

Thanks by advance for any help !

Upvotes: 4

Views: 1011

Answers (1)

huzeyfe
huzeyfe

Reputation: 3704

Testing is a very crucial part in software lifecycle but it is always underestimated or ignored. In general cases it is advised that Unit Tests should not depend any data or database however integration tests are a little bit different and mostly requires a sufficient set of data.

Ideally for integration tests there should be an integration server which has a proper database and sufficient data. If you do not a have an integration server yet fixtures in Play Framework is the easiest and simplest way of having proper data before tests.

In Play Framework there are three types of tests. Unit and Functional tests are JUnit test and Selenium tests are also known as acceptance tests. All these concepts are actually outside of Play Frameworks core model except some really handy recipes on them. So, to be honest I could not understand the concern about using this structure. For instance, you can use either Selenium native syntax or use the #{selenium /} tags..

Fixtures are also quite handy and if you use them efficiently they are pretty useful. I mean by efficient that you can split up your data i.e. users.yml, products.yml etc. and load delete them independently and this gives you flexibility in you tests.

Up to now if you are not convinced to use fixtures than you could consider mock data but I don't prefer mock data in integration tests. Here is an example of mocking test data and this is outside the Play Framework ;)

Mockito

To be honest I've not got any chance to play with library but if you have time it seem worth giving a try to it.

I hope this answer helps you.

Upvotes: 1

Related Questions