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.

General Questions /

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

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

TestFramework errors & questions


Reply


6 Posts   979 Views

Avatar
dompie

Community Member, 88 Posts

16 November 2010 at 1:28am

Edited: 16/11/2010 1:33am

Hi, I have tried to run some tests but am stuck with the following error message when trying to run dev/tests/SapphireTest

[User Error] TestRunner::only(): Invalid TestCase 'SapphireTest', cannot find matching class


I've found the required files in the filesystem and tried to move them...what brings up another errormessage, so I switched them back again and wrote this post.

Another issue: When running dev/tests/all I only receive a list of tests, but nothing that indicates a failures or success.

And last thing: when calling /dev/tests/coverage - is this page left blank intentionally?

I'm running this stuff on SS 2.4.3, Ubuntu with PHPUnit 3.4.5 installed. Any hints are welcome :)

Avatar
swaiba

Forum Moderator, 1804 Posts

16 November 2010 at 3:14am

Quick check...

Director::set_environment_type("test");

... is in your config?

Avatar
Willr

Forum Moderator, 5513 Posts

16 November 2010 at 8:54pm

[User Error] TestRunner::only(): Invalid TestCase 'SapphireTest', cannot find matching class

Sounds like you're trying to run the SapphireTest? That itself is not a test so you have to give it either a test case, module name or all.

running /dev/tests/all should run all the tests and /dev/tests/ should show the list of all the tests. Make sure that page isn't just loading. If it doesn't work in a browser try using sake.

Running the full test suite can take a while on some databases (I'm sitting at ~5 mins for full suite on mysql). One trick we employ is using SQLite3 when running tests which reduces it massively see https://github.com/chillu/silverstripe-doc-restructuring/blob/master/master/sapphire/docs/en/howto/phpunit-configuration.md

Avatar
dompie

Community Member, 88 Posts

18 November 2010 at 4:00am

Edited: 18/11/2010 4:17am

Well, I'm trying this on my development environment. I assume tests work also in 'dev' mode.

browser
Running /dev/tests/all takes about 5 seconds and the output looks like: - absolutely no hints about failures.

All I want is to run CurrencyFieldTest and see what failures occour (if any). So I tried calling /dev/tests/CurrencyFieldTest but the output always remains the same, no matter what I put in /sapphire/tests/forms/CurrencyFieldTest.php:

sake
Sake behaves similarly. It takes only about 1 second and produces no output (except some self-produced notices) when starting it by:
./sapphire/sake /dev/tests/all
or
./sake /dev/tests/all

Avatar
Willr

Forum Moderator, 5513 Posts

18 November 2010 at 2:24pm

Try checking out your php error log, something could be segfaulting or another possible issue is if you have a loose die lying around in your code or some config files. Seen people if if(!$var) die(); and $var may not exist when running tests. Hopefully you get an error message to start off with.

Avatar
dompie

Community Member, 88 Posts

18 November 2010 at 11:11pm

Ah, found it:

PHP Fatal error: Couldn't run query: \nCREATE DATABASE `tmpdb5733285` \n\nAccess denied for user 'devel'@'myhost.de' to database 'tmpdb5733285' in /silverstripe_base/sapphire/core/model/MySQLDatabase.php on line 526, referer: http://127.0.0.1/dev/tests

My Database user had only usage privileges...the super privilege fixed this (adding only create privilege does not help much, due to "check" queries). Increasing memory limit (php.ini) to 256MB was also required, 128MB was not sufficient. Thanks a lot!