CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Unit Testing (Moderator: Michał Mach) »
  • CiviSeleniumSettings.php??
Pages: [1]

Author Topic: CiviSeleniumSettings.php??  (Read 3024 times)

torenware

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 4
CiviSeleniumSettings.php??
May 21, 2010, 05:34:27 pm
I'm setting up unit testing off the v3.2 branch, and the xx script craps out immediately with the error:
Quote
Warning: CiviSeleniumTestCase::require_once(CiviSeleniumSettings.php): failed to open stream: No such file or directory in /home/rtoren/svn_sandbox/CiviCRM/branches/v3.2/tests/phpunit/CiviTest/CiviSeleniumTestCase.php on line 63

The file CiviSeleniumSettings.php is nowhere in the tree, it appears, so I'm guessing this is an undocumented settings file.

I'm willing to change the docs, but what is this file and what should it contain?


torenware

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 4
Re: CiviSeleniumSettings.php??
May 21, 2010, 05:42:04 pm
OK, I found the template file in tests/phpunit/CiviTest.

The file needs comments.  It isn't clear what the different settings refer to:
Code: [Select]
<?php

class CiviSeleniumSettings {

  var 
$browser = '*firefox';

  var 
$sandboxURL = 'http://tests.dev.civicrm.org';

  var 
$sandboxPATH = '/drupal/';

  var 
$username = 'demo';

  var 
$password = 'demo';


  function 
__construct() {
    
$this->fullSandboxPath = $this->sandboxURL . $this->sandboxPATH;
  }

}
?>



torenware

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 4
Re: CiviSeleniumSettings.php??
May 21, 2010, 06:12:35 pm
I've stubbed in some documentation at http://wiki.civicrm.org/confluence/display/CRM/Setting+up+your+personal+testing+sandbox+HOWTO.  It needs work, since I don't really understand if the test system needs a separate database from your sandbox install or not.  Typically, test systems assume they can trash a database.  If that's the case, you probably don't want to give phpunit free rein.

So somebody on the CRM team needs to look at the doc and bring it up to date.  In addition, it would be helpful if there's a "hello world" test in the test suite, so somebody can do the following to see if the test stuff is correctly installed:

Code: [Select]
scripts/phpunit -u db_username -pdb_password -h db_host test_hello_world_class


At this point, it's hard to get this stuff up, and if the team wants this stuff used in the wild, the docs need to be a bit closer to where the tree is at.

torenware

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 4
Re: CiviSeleniumSettings.php??
May 22, 2010, 02:14:39 pm
In general, there needs to be some specific documentation how to set up for Selenium testing in CiviCRM.

I'm getting the CRM test suite to run generally, but all the Selenium tests fail.  The error is typically like this:
Code: [Select]
2) WebTest_Contribute_StandaloneAddTest::testStandaloneContributeAdd
PHPUnit_Framework_Exception: Could not connect to the Selenium RC server.

This isn't a big deal for me, since I'm putting together a custom test suite; I don't need all of the standard tests to work.  But it would be good if people outside of the core team could run these tests, since it will help improve the quality of the code generally.

Michał Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: CiviSeleniumSettings.php??
May 24, 2010, 06:22:24 am
Hey Rob,

Can you make sure that selenium server is running? I've updated wiki docs a bit - please refer to: http://wiki.civicrm.org/confluence/display/CRM/Setting+yourself+up+to+work+with+Selenium+tests for details.

Thx,
m
« Last Edit: May 24, 2010, 06:34:56 am by Michał Mach »
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

Michał Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: CiviSeleniumSettings.php??
May 24, 2010, 06:53:59 am
Hey Rob,

Thanks for trying out tests and your remarks on documentation. It would be most helpful for me if you could sketch out layout for testing installation/getting up to speed documentation, from 'outsider' perspective. I've been working on making all those things run and kind of lost perspective on what's important and what's not on installation process - so having the outline coming out from fresh experience would help in reordering/tidying testing docs a lot.

Thx,
m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

torenware

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 4
Re: CiviSeleniumSettings.php??
May 24, 2010, 02:40:21 pm
Quote from: Michał Mach on May 24, 2010, 06:53:59 am
Hey Rob,

Thanks for trying out tests and your remarks on documentation. It would be most helpful for me if you could sketch out layout for testing installation/getting up to speed documentation, from 'outsider' perspective. I've been working on making all those things run and kind of lost perspective on what's important and what's not on installation process - so having the outline coming out from fresh experience would help in reordering/tidying testing docs a lot.

Thx,
m

I'll give that a shot.  I didn't find the link in the wiki before now -- we should add that link to the main test page, since the regular install will fail if Selenium is not either set up or commented out -- but I went to the Selenium web site and figured out that the Java server needed to be running.  I even installed it myself, since I didn't know it was already in the tree.

It's also a good idea if the settings file adds comments to explain what password and user is being talked about (ans: the Drupal user that Selenium uses to log in), and also what access rights that user needs (looks like the combination of at least "administer civicrm" and "access civicrm" are both needed; there may be more).

It would be good generally if there are instructions for running a subset of the tests that are bit more clear;  AllTests is a big set of tests, and a lot of things can go wrong, including the odd seg fault.  So it should *not* be the first thing people try when they get set up.  I set up my own test directories by doctoring the phpunit script a bit.  The test looks like this:
Code: [Select]
<?php

/**
 * @file HelloTest.php
 *
 * This is a simple test to make sure that you have phpunit
 * correctly installed and working. The call will look something like:
 *
 * <code>
 *   scripts/phpunit HelloTest
 * </code>
 *
 * If your script (which would need to be in HelloTest.php) is found and runs,
 * UR DOIN IT RIGHT!
 */

require_once 'PHPUnit/Framework/TestCase.php';

class 
HelloTest extends PHPUnit_Framework_TestCase
{
// contains the object handle of the string class
var $abc;


function __construct( $name = NULL)
{
parent::__construct( $name );
}

// called before the test functions will be executed
// this function is defined in PHPUnit_TestCase and overwritten
// here
function setUp() {
// create a new instance of String with the
// string 'abc'
$this->abc = "hello";
}

// called after the test functions are executed
// this function is defined in PHPUnit_TestCase and overwritten
// here
function tearDown() {
// delete your instance
unset($this->abc);
}

// test the toString function
function testHello() {
$result = $this->abc;
$expected = 'hello';
$this->assertTrue($result == $expected);
}
}
?>


Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Unit Testing (Moderator: Michał Mach) »
  • CiviSeleniumSettings.php??

This forum was archived on 2017-11-26.