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 (Moderator: Donald Lobo) »
  • Using SimpleTest?
Pages: [1]

Author Topic: Using SimpleTest?  (Read 1813 times)

dharmatech

  • I post frequently
  • ***
  • Posts: 280
  • Karma: 53
    • dharmatech.org
Using SimpleTest?
December 30, 2008, 07:29:25 pm
Hi All,

I'd like to run the regression tests, but after checking out r19019 from svn.civicrm.org/civicrm/trunk and trying various things I am thoroughly confused  :(  Any help would be welcome.

TIA  -- Walt
http://dharmatech.org
oss@dharmatech.org
801.541.8671

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Using SimpleTest?
December 31, 2008, 05:40:43 am

Walt:

Might be best to get on IRC so that we can walk you through it. We'll ensure that the tests are up and running and complete in trunk also in the next day or so

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

dharmatech

  • I post frequently
  • ***
  • Posts: 280
  • Karma: 53
    • dharmatech.org
Re: Using SimpleTest?
December 31, 2008, 05:41:45 pm
I've made some progress toward just integrating the CiviCRM unit tests with the Drupal 6 simpletest module.  That seems like a convenient solution for a group that delivers integrated Drupal/CiviCRM solutions  :)

I said "some" progress, I'll probably ask for help again, when I'm confused at a higher level about more important things  ;)

So far I've established that the "recommended" simpletest-6.x-2.5 version is incompatible with most if not all of the existing Drupal and CiviCRM unit tests.  ARGH!!!  Had to back it out and use simpletest-6.x-1.2.

If I manage to make this idea work, I'll send in the code.

All this because Tony said he wanted me to test something  :)

Happy New Year!

-- Walt
http://dharmatech.org
oss@dharmatech.org
801.541.8671

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Using SimpleTest?
January 01, 2009, 06:29:35 am

we need to upgrade and incorporate the latest simpletest module for our needs. I think we should do this for 2.2

we have hacked the module to allow tests to reside within the civicrm directory structure, so you might still need to use the "hacked" version of simpletest module (which is in our svn tree at: packages/drupal)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

dharmatech

  • I post frequently
  • ***
  • Posts: 280
  • Karma: 53
    • dharmatech.org
Re: Using SimpleTest?
January 01, 2009, 07:07:41 pm
Well I have Drupal 6 simpletest showing a list of CiviCRM tests generated from the tests/ directory that I downloaded from the CiviCRM repository.  Here are the gotchas:

  • I have to start the test session by installing the CiviCRM database from the distributed sql/civicrm.mysql then initializing it from the distributed sql/civicrm_generated.mysql .  This of course wipes out any existing database.
  • I can then run certain tests, but certain combinations of test conflict with each other by generating for example custom groups with the same name (test_group).
  • I can't rerun a test because of the way the tests initialize, as above.

I haven't attempted to write code to initialize the database.  It makes me nervous that somebody would run a test and wipe out their database.  Initializing the database from the beginning is OK for software development but I wouldn't want to put anything that dangerous into untrained hands.

The way the Drupal 6 unit tests work is by generating names like simpletest_something and simpletest_somethingelse for test data.  The Drupal simpletest module attempts to clean all this up when you click on the appropriate button, but of course the cleanup isn't really total.  Still if you see a user with a name like simpletest_x3HjZ7i you know this is not the usual kind of user  :)

So here is the code I wrote, all 16 lines of it  :) and the installation instructions.

  • Install the CiviCRM unit test library in the usual place, ie. .../modules/civicrm/tests
  • Create a new directory .../modules/civicrm/drupal/tests
  • Get the attached file civicrm.test.txt and rename it to civicrm.test (stupid BB  >:( )
  • Put the new file civicrm.test in the new directory .../modules/civicrm/drupal/tests
  • Install version 6.x-1.2 of the Drupal simpletest module.  Ignore the recommendation to use 6.x-2.5 (stupid writer  >:(  )
  • Download and install the Simpletest library in Drupal in ...sites/all/modules/simpletest
  • Go to Drupal page Administer >> Site building >> Modules and enable Simpletest
  • Got to Drupal page Administer >> Site building >> Simpletest .  You should see two groups of CiviCRM tests listed
  • Before you can actually run these tests you need to initialize your CiviCRM database with e.g. the MySQL command line tool by first applying .../modules/civicrm/sql/civicrm.mysql to create the empty database, then .../modules/civicrm/sql/civicrm_generated.mysql to install test data

Have fun!

-- Walt
http://dharmatech.org
oss@dharmatech.org
801.541.8671

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Using SimpleTest?
January 01, 2009, 07:32:07 pm

all civicrm unit tests are supposed to clean up after themselves :) If you find tests that dont do so, please file an issue (and preferably a patch) against that test and we'll fix it for 2.2

We'll try upgrading simpletest to the latest version and incorporate your instructions as part of the code base

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Using SimpleTest?

This forum was archived on 2017-11-26.