Jump to:

23550 Posts in 19338 Topics by 2890 members

General Questions

SilverStripe Forums » General Questions » TestFramework errors & 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

Page: 1
Go to End
Author Topic: 938 Views
  • dompie
    Avatar
    Community Member
    88 Posts

    TestFramework errors & questions Link to this post

    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

  • swaiba
    Avatar
    Forum Moderator
    1796 Posts

    Re: TestFramework errors & questions Link to this post

    Quick check...

    Director::set_environment_type("test");

    ... is in your config?

  • Willr
    Avatar
    Forum Moderator
    5511 Posts

    Re: TestFramework errors & questions Link to this post

    [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

  • dompie
    Avatar
    Community Member
    88 Posts

    Re: TestFramework errors & questions Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5511 Posts

    Re: TestFramework errors & questions Link to this post

    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.

  • dompie
    Avatar
    Community Member
    88 Posts

    Re: TestFramework errors & questions Link to this post

    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!

    938 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.