Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Test driven development


Go to End


5 Posts   1557 Views

Avatar
Mo

Community Member, 541 Posts

20 November 2013 at 6:52am

Hi All,

I am trying to *finally* get my head into test driven development, but am repeatedly stumbling on an annoying hurdle.

Every time I try and run dev/tests/all it uses an obscene amount of RAM and never seems to finish. This happens when using the browser or sake.

At the moment I am trying to run the test suite using the option of pulling down unit testing libraries via composer, but have also tried setting up php unit via PEAR in the past and had similar results.

I am using a Sony VAIO E14:
Linux Mint 14
Core i5
8gb RAM
PHP 5.4
Apache 2.2 (possibly 2.3)

Not really sure where to go to diagnose this problem, anyone had a similar problem?

Cheers,

Mo

Avatar
Willr

Forum Moderator, 5523 Posts

28 November 2013 at 10:58pm

Do you at least see a bit of progress? (dots going by..)

Tests/all will be very slow. Even on my SSD apple HD the full test suite on MySQL can take 5 minutes to run. For doing test driven development I recommend 2 things:

- Only work on one test case at a time. No point running tests/all. Either run a single test - dev/tests/MyApplicationTest or the tests for your module: dev/tests/module/mysite to run all your mysite tests.

- If you can, have sqlite3 installed for tests. If you're not doing SQL heavy work SQLite is much faster to bootup and is normally accurate for simple applications. Most devs will have a switch in _config.php which detects if sake + something like GET['sqlite'] exists and run tests like sake dev/test sqlite=1

Avatar
swaiba

Forum Moderator, 1899 Posts

29 November 2013 at 2:41am

Just to follow on from Willr - the main benefit of SQLite is that it can be run in memory and then is lightning fast. To import a database (on the slightly older versions) of sqlite you have to do a funny extended insert to prepare a database (see http://stackoverflow.com/questions/1609637/is-it-possible-to-insert-multiple-rows-at-a-time-in-an-sqlite-database - I could post my backup and restore functions if of use?)

also if you are starting out review behat (see http://vimeo.com/77432122 )

historically I've avoided phpunit and we have a homegrown testing suite - that is now being merged with behat solution due to the natural language approach.

Avatar
camfindlay

Forum Moderator, 267 Posts

30 November 2013 at 10:35am

There is a post over here http://deadlytechnology.com/silverstripe/sqlite-unit-testing/ that mentions putting a switch in your config file to turn on when running tests. Worth checking out.

Avatar
Mo

Community Member, 541 Posts

27 February 2014 at 10:59pm

Hi Guys,

Many thanks for the responses, I will watch and read through everything and then see if I can finally get my head round unit testing :-).

Mo