-
Notifications
You must be signed in to change notification settings - Fork 2
Testing
A note on continuous integration |
---|
While a Travis CI server is setup and has been used successfully with this application in the past, the CI server is currently non-functional because we've removed the database passwords and such from the repo and have not yet updated Travis CI to be able to be able to get the passwords from encrypted keys. |
Once the program has been setup as per the readme, you testing requires a simple one-time setup.
- In the
conf/application.conf
file, there is a section for the test database (which must be a separate database in order to run the tests). Provide appropriate credentials in that file. - Run the
database/CreateTables.sql
file and thedatabase/test/testDatabase.sql
on that database.
Note |
---|
In order to run the browser tests, you need to be on Windows and have Google Chrome, Internet Explorer 11, and Firefox installed. |
Unit and integration tests are run with:
./activator "test-only *MainTests`"
Browser tests (which test that the site works in that browser) are run with:
./activator "test-only *BrowserTests`"
You can also run tests individually with ./activator "test-only TestName"
.
Testing of EatSafe is done through the Play Frameworks integrated testing suite that uses spec2, a specification framework for Scala. Play also gives us access to the powerful browser-based testing of Selenium, via FluentLenium, which is just a more Scala way of using Selenium.
Using Spec2 we can write individual unit tests, application tests using the mocked routing/application system (provided within the suite), as well as live application integration and end to end tests using a real version of the application and/or a browser.
The tests within our system are split into two groups, MainTests and BrowserTests, the MainTests include unit, integration tests, and end to end tests. These MainTests (Files ending in "MainTest.scala" in the test
folder) serve as our application smoke tests as they are run on every commit of the repository on a Travis CI server.
These automated tests cannot be run by the CI server, so they must be run on a Windows machine with the browsers installed. These tests do expanded versions of some of the MainTests in a real browser environment, and as such, you need the actual browsers on your computer to be able to run them.
As a note on convention, if you create a new test file, any tests you want to be run on the CI server/ during the main set of tests should be suffixed with 'MainTests.scala' as the end of the file name, and Browser Specific tests should be suffixed with 'BrowserTests.scala' any other tests you would like to create that do not fit under these two categories can be named however you like.