Needs work
Project:
Drunit - PHPUnit and Selenium RC integration for Drupal
Version:
6.x-0.5-beta1
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
8 Feb 2011 at 17:29 UTC
Updated:
2 Jan 2014 at 19:06 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
andreiashu commentedSorry, that was the wrong patch.
Attached patch should apply ok.
Comment #2
andreiashu commentedThis is an implementation that uses this patch: #1048748: Add functional tests
Comment #3
_rune commentedHi andreiashu
First of all, thanks for the cool patch! It looks like you know what you are doing so I added you as a maintainer of the drunit and commited the patch to CVS. I think it's a great starting point for moving drunit forward!
I have several thoughts about the patch, but got stuck on trying to make it run the testDrunitClassExtends correctly. In the process I changed an include to use the PHPUnit version 3.5.10 way of bootstrapping. I also needed to set error_reporting to 0 in my php.ini file due to some double imports, will look into that.
Are very busy the next couple of weeks but then it should ease out. Bare with me!
Cheers
Rune
Comment #4
andreiashu commentedHi Rune,
Thanks for your quick reply and adding me as a co-maintainer.
I didn't do any PHP.ini modifications, but at the same time my version of PHPUnit is 3.4.15. Things might have changed in the 3.5 version. I'll try to look into that.
Also, I didn't test this under a complete new Drupal install so I need to do that too.
We should be ported to GIT very soon (should happen sometime this month) so I'll probably start committing stuff when that has been done :-)
I'm going to mark this issue as needs work because of things that we need to look into regarding 3.5 version of PHPUnit.
Cheers,
Andrei
Comment #5
andreiashu commentedThe attached patch should hopefully fix this problem. I know you said you are going to be busy during the next few weeks, so it's no rush.
EDIT: please see this issue regarding this particular problem.
Comment #6
andreiashu commentedForgot to add: for testing this I compiled a standalone version of PHP 5.3.5. I also downloaded the latest PHPUnit from GitHub. I was getting some errors about PHP not being able to find PHPUnit required files so I added this to my php.ini.cli:
It might not be necessary for your install though (if you installed php and pear via apt-get for example).
Comment #7
_rune commentedOk some first thoughts.
== drunit_drush_phpunit3.5.patch ==
Looks good!
== Comment#6 ==
Used pear and everything was fine after I updated pear to 1.9.1 using pear :)
== drunit_drush_integration_1.patch ==
1) Naming of test folder, "tests" or "drunit".
Thinks it is cleaner and more explicit to not mix drunit tests and Drupal Simpletests. That would also make most of the code in drunit_test_get_all_classes() go away.
2) Drush integration.
All three of "drunit-list", "drunit-run" and "drunit-run-all" is easily accomplished by using the phpunit command with simple switches. I'm constantly using a number of switches like "--stop-on-error", "--tap", "--wait" and "--coverage-html" and it seems messy (for not to mention boring:) to port all switches of PHPunit to the drush-run* scripts.
3) DrunitTestListener.
Never used one of those, whats the advantages to the standard PHPUnit run?
4) Moving settings to main settings.php
Thats a lot better than having a separate settings file! Think the "_conf" postfixes can be omitted. There is going to be some funkiness regarding precedence if we want to keep the option to run with xml configuration files too.
5) support for *AndAjaxWait function calls
Of __call magic thats not too bad, and looks usable!
6) The selenium* methods
Should be made available through a class var instead, with the code in its own class, see 9? Extremely useful!
6a) seleniumCreateNode
Think the method definition could be something like
seleniumCreateNode($nodeType, $data, $settings)
It also looks too specific.
7) The drupal* methods
Should be made available through a class var instead, with the code in its own class, see 9? Extremely useful!
8) The random* methods
Should be moved to a DrunitRandom class?
9) selenium*, drupal*
This represents two ways of manipulating the site. I've also worked on simply posting and getting by changing the $_POST, $_SET, $_SESSION, etc. global variables and then inside an output buffer including the index.php file. Works quite well too and is a lot faster than running selenium. What's a good category name for these three types? And what would be a good way to provide access to these in the test classes?
Ok thats it for now
Cheers!!!
Rune
EDIT: Removed notions of using DI.
Comment #8
_rune commentedTesting email notificatons.
Comment #9
andreiashu commented1) I don't understand. You mean to have drunit as a folder naming convention where we keep all the PHPUnit tests instead of "tests"?
Regarding mixing PHPUnit tests with Selenium tests: agreed but I'm not sure what is the best way to proceed because Selenium, for PHPUnit, is just a subclass of the main PHPUnit test class. Do you think in the future there might be other subclasses that we need to include?
2) Drush integration: agreed, it's not good to duplicate the functionality provided in PHPUnit. Although I do remember that I had a reason for duplicating it in the first place.... If I remember correctly, the whole idea of integrating with Drush is to have access to a bootstrapped Drupal environment. To be honest I don't know how we could directly pass the argument from drush to the
PHPUnit_TextUI_TestRunner::runmethod... Any suggestions are welcome.3) DrunitTestListener: Initially I've created it just as a means of debugging. I left it there for the same reason. We can remove it at any point but at the same time it gives more flexibility if you want to output the results in a different format.
4) Yup, removing "conf_" prefix is ok. Re xml configuration: I don't have too much experience with that. I know you can add a lot of things like multiple browsers for selenium testing and such but I never actually used it.
8) Probably moved to a DrunitUtils class where we keep all the useful static methods like this. I also noticed that I left some copy-paste code form simpletest module there:
str_replace('simpletest', 's', $db_prefix) . $str9) Re selenium*, drupal*:
Initially I tried to have inheritance from PHPUnit + Selenium, but unfortunately we can't have multiple inheritance in PHP (and the workarounds are not ok). Subclassing from simpletest would have been great because could have ran everything from there (think about installing a new instance of Drupal, running simpletests/phpunits/selenium tests and then cleaning it). But for now we are left with simply copying some of the functionality form Simpletest module (the drupal* methods).
I'll try and have a look at it again during the day because now it's pretty late and I'm not sure how sane my thoughts are.
Cheers,
Andrei
Comment #10
_rune commented1) Yes I mean to simply use "drunit" instead of "tests". "tests" is already "occupied" by Drupal Simpletest. I thinks it is ok to mix PHPUnit and Selenium tests in the "drunit" folder.
2a+4) http://www.phpunit.de/manual/3.5/en/phpunit-book.html#organizing-tests. You did it "Using the TestSuite Class" and I did it "Composing a Test Suite Using XML Configuration". I don't know whats best, needs experimentation and writing about pros and cons.
2b) I don't think we should use Drush just for its bootstrapping features as it is pretty simple to do standalone.
3) Nuke it, things not used should die! :)
8) Don't like the notion of an "Utils" class, they often end up being a messy dump of all the code you don't now where to place. Thats why I mentioned the "Random" class.
9) Even without multiple inheritance (or traits:) we could easily have something like:
Take care!
Rune
N.B.: Oh and by the way. At least where I'm at, if you google for "phpunit" the Drunit page is second :)
Comment #11
andreiashu commented1) "drunit" folder is ok for me.
2a+4) Please correct me if I'm wrong but for Drunit + Drush it seems to me that the TestSuite class method is the only way of actually running the tests.
2b) Not sure what you mean. Without having Drush integration we would revert back to having to set the manual includes, and the XML generation. With Drush it's just a matter of setting the path to Drush.
3) ok :)
8) We can make sure that a "Utils" like class wouldn't end up a messy dump of code but I don't really mind having separate classes for static functionality either.
9) I like the
$this->selenium->doSomethingapproach!I think I'll be able to provide a new patch for this sometime next week.
Re Google for phpunit: I think it's valid just for you. Try to logout of gmail (and any other google related services) and clear cookies and see if you can still find it in the second place :) For me it doesn't happen for sure.
Cheers,
Andrei
Comment #12
_rune commented1) "drunit" it is then.
2a+4)
Yes, shy of doing a system() call to the phpunit executable :) OK, lets ditch the XML config hell, who uses XML anyway :)
2b) I don't mind the manual includes and am not the biggest fan of adding Drush as a dependency but I guess it is the de facto standard of running Drupal from the command line. Am a bit worried that it will give E_NOTICE's though. Lets try Drush out!?
8) Good plan about not making a mess, agreed!
9) "$this->selenium->doSomething" is agreed upon!
> I think I'll be able to provide a new patch for this sometime next week.
Sweet. Am deep inside a Django project a.t.m. so am mostly in Python-land, but will try to find some time!
Cheers!
Rune
Comment #13
glennpratt commentedSubscribe... looks like some of this stuff has been committed according to the git logs?
Comment #14
_rune commentedYes the patch "drunit_drush_integration_1.patch" is in the repo. Can't wait....git is coming!!!
Comment #15
andreiashu commentedSorry for the delay, I now reckon I have some time to put into drunit :)
Regarding #5: I'll put that into a separate issue as I think we should deal with it separately.