Skip to content

Commit

Permalink
Merge branch 'master' of github.com:playframework/play
Browse files Browse the repository at this point in the history
  • Loading branch information
pepite committed Aug 25, 2011
2 parents dc29ccd + b8cb66e commit f5dc1c7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions documentation/cheatsheets/tests/ch24-TestDataloader.textile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
h2. Test - Data loader

*==@Before public void setUp() { Fixtures.deleteAll();==*
*==Fixtures.load("data.yml");}==*
*==Fixtures.loadModels("data.yml");}==*
Fixtures is used to initialise the datastore before running a unit test

*==#{fixture delete:'all', load:'data.yml' /}==*
*==#{fixture delete:'all', loadModels:'data.yml' /}==*
*==#{selenium} ... #{/selenium}==*
Same idea using a Selenium test
8 changes: 4 additions & 4 deletions documentation/manual/guide10.textile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
h1. Completing the application tests
loadModels:h1. Completing the application tests

We’ve now finished the blog engine we wanted to create in this tutorial. However the project itself is not yet completely finished. To be totally confident with our code we need to add more tests to the project.

Expand Down Expand Up @@ -76,7 +76,7 @@ This test should run without any problem with the yabe application. It just open

However like any complex test, you need to set-up a set of well-known data before navigating the application and testing it. We will of course reuse the fixture concept and the @yabe/test/data.yml@ file that we’ve used before. To import this data set before the test suite, just use the @#{fixture /}@ tag:

bc. #{fixture delete:'all', load:'data.yml' /}
bc. #{fixture delete:'all', loadModels:'data.yml' /}

#{selenium}
// Open the home page, and check that no error occurred
Expand All @@ -89,7 +89,7 @@ Another important thing to check is that we have a fresh user session at the tes

So let’s start our test with a special command:

bc. #{fixture delete:'all', load:'data.yml' /}
bc. #{fixture delete:'all', loadModels:'data.yml' /}

#{selenium}
clearSession()
Expand All @@ -104,7 +104,7 @@ Run it to be sure that there is no mistake. It should be green.

So we can write a more specific test. Open the home page and check that the default posts are present:

bc. #{fixture delete:'all', load:'data.yml' /}
bc. #{fixture delete:'all', loadModels:'data.yml' /}

#{selenium 'Check home page'}
clearSession()
Expand Down
6 changes: 3 additions & 3 deletions documentation/manual/test.textile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
h1. Test your application
loadModels:h1. Test your application

Creating automatic test suites for your application is a good way to make it robust. It allows you to work in a very agile way.

Expand Down Expand Up @@ -166,7 +166,7 @@ p(note). You can read more about Play and YAML in the "YAML manual page":yaml.

For Selenium tests, you can use the @#{fixture /}@ tag:

bc. #{fixture delete:'all', load:'data.yml' /}
bc. #{fixture delete:'all', loadModels:'data.yml' /}

#{selenium}

Expand All @@ -180,7 +180,7 @@ bc. Fixtures.loadModels("users.yml", "roles.yml", "permissions.yml");

and for Selenium tests:

bc. #{fixture delete:'all', load:['users.yml', 'roles.yml', 'permissions.yml'] /}
bc. #{fixture delete:'all', loadModels:['users.yml', 'roles.yml', 'permissions.yml'] /}

h2. <a name="running">Running the tests</a>

Expand Down
6 changes: 4 additions & 2 deletions framework/templates/tags/fixture.tag
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
}%

%{
if(_load) {
play.test.Fixtures.load(_load)
if(_loadModels) {
play.test.Fixtures.loadModels(_loadModels)
} else if(_load) {
play.test.Fixtures.loadModels(_load)
}
}%

Expand Down
2 changes: 1 addition & 1 deletion resources/application-skel/test/data.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# you describe your data using the YAML notation here
# and then load them using Fixtures.load("data.yml")
# and then load them using Fixtures.loadModels("data.yml")

# User(bob):
# email: [email protected]
Expand Down

0 comments on commit f5dc1c7

Please sign in to comment.