Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
simpletest.module
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
20 Sep 2010 at 00:18 UTC
Updated:
3 Jan 2014 at 02:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
c960657 commentedThis have been on my wish list for ages.
Based on a rudimentary review and test, this looks good.
A style nit:
I think $failed_methods should rather be named something like $test_methods—whether they failed in the last test run is not really relevant for the current test run (and I guess you could imagine other cases where you want to run only a specific test function).
I think would be more intuitive if the method array immediately followed the test array in function argument lists, or perhaps the two could be merged into one array like
array('class1' => TRUE, 'class2' => array('testFoo'))(meaning run everything in class1 but only testFoo() in class2). I think this will make the new feature more like an integrated part of the API.The preg_match does not work with code like this:
When I try to run the failed test, it completes a test run with no tests (I think) and ends up with this error message:
These counts are not really comparable. I wonder whether it would be better to show e.g. “Classes with failing tests (3 classes)” and “Methods with failing tests (4 methods in 3 classes)”. In fact I think the current wording is rather confusing, because it is not obvious what the numbers refer to.
Comment #2
sunI actually played with the idea of just doing the change to DrupalTestCase::run(). That is, because most often, I don't even want to run other test methods in the first place; i.e., for the initial test run already. So I'm currently considering to implement some AJAX goodness to retrieve individual test methods of a test class on the initial test selection form already.... possibly for Devel module.
Comment #3
sunI think this is too much for D7, so we should just allow an advanced SimpleTest UI in contrib to run selected methods (without having to entirely replace SimpleTest module and/or DrupalWebTestCase -- if that is possible at all).
Comment #4
sunProper title for the much more focused goal.
The idea is that Devel or some other module in contrib is able to expose a different UI for running tests, allowing to not only select entire test cases to run, but more granularly select, which test methods in a test case should be run. Most often, you are only interested in one or two, but not any other method.
Comment #5
webchickInteresting.
This looks like a low-impact change that could bring a lot of benefits and help with spreading TDD in Drupal. Agreed with not changing around the UI at this stage.
Comment #6
aspilicious commentedwhen retesting it could be that other changes in core affected several other testcases. So you cannot ensure you covered everything just by doing a retest on the test that failed previously.
(for example when there is to much time between a test and a retest)
You have to take care of that too.
Comment #7
sun@aspilicious: Sure, you (or the testbot) can still run entire test cases or all tests. However, I most often know what I'm doing, so I have zero need for running tests that have nothing to do with the changes I'm performing.
Comment #8
sun#3: drupal.simpletest-failed-methods.3.patch queued for re-testing.
Comment #9
sunAdded phpDoc. This change cannot be really tested without implementing the functionality to run only certain methods in core. Thus, I think that this patch is ready to fly.
Comment #10
sunAny feedback?
As mentioned before, this change cannot really be tested, as that would imply to do what it's intended for in Drupal core. :P
Comment #11
c960657 commentedI tested this by hardcoding some arguments for run().
Comment #12
dries commentedMight be good to provide an example of how this is supposed to be used when writing tests.
I doubt this is easier than commenting out some test functions but maybe I fail to see the use case.
Let's be more explicit about how this improves our lives.
Comment #13
webchickSounds like Dries's comment can be summarized as "needs more documentation", thus needs work.
Comment #14
sunQuoting myself:
To summarize:
DrupalWebTestCaseclass and PHP OOP does not allow anyone to override individual class methods, there is no way to write a contributed module as replacement for SimpleTest module that would allow to run certain test methods only.For that sake, reverting to RTBC.
Comment #15
moshe weitzman commentedI've just committed a test-run command to drush and at sun's suggestion, I've added support for this fine new parameter. So, we now have our use case committed and value has been proven IMO. Agree with RTBC.
Comment #16
webchickI think a module that exposed a UI for this would be a complete and absolute nightmare, but the drush application has quite a few uses. Someone could set up their own "testbot lite" that just runs the most critical test cases for the major business logic of their Drupal site. Or even for run-of-the-mill core developers, to just hit up + drush test FooWhateverKeepsBreakingTestCase as they're drilling into a patch.
However, the "needs documentation" issue in #12/#13 still hasn't been addressed. In other words, there are details in this issue that aren't remotely hinted at in the code. Let's get some "why" stuff in there. Maybe something like:
(Obviously, with the formatting vastly cleaned up :P)
And this seems more like an API addition than an API change; there's nothing existing test authors need to adjust.
Comment #17
sunAlright, incorporated the suggestion in #16.
Comment #18
klausiFixed a typo ("unless a specific list" instead of "unless as specific list")
Comment #19
dries commentedOK, the extra documentation is helpful. Committed to CVS HEAD.