Problem/Motivation
We are converting all our test cases to use PHPUnit which is a well known and well supported test runner. Maintaining the Simpletest UI is a lot of work, we should rather spend our resources on good developer docs for running our PHPUnit tests from the command line and from IDEs.
Note: You can get the same output as with the simpletest UI using --browser --verbose
. This issue is about mostly the listing page of all available tests.
Proposed resolution
Remove Simpletest's UI as soon as 90% of our test cases are converted to PHPUnit tests, see also #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase).
Remaining tasks
Discuss the consequences of removing Simpletest UI and build agreement.
User interface changes
No more running test cases from Drupal's UI.
API changes
Since this change only affects test code and not end user facing features it is exempt from the API and UI change policies.
Data model changes
none.
Comments
Comment #2
klausiI was quite bold with the issue summary, feel free to edit and correct!
Comment #3
larowlanI'm +1 for this, there are graphical runners for phpunit, and most are using phpstorm anyway.
Comment #4
Mile23Removing simpletest UI is the same thing as removing simpletest module. This issue should be titled: Quit supporting the simpletest UI by refactoring the non-UI parts of simpletest into core and removing the simpletest module.
I'm -1 on removing the UI and thus the module. I'm +1 on the refactoring part.
Comment #5
klausiWe will do all necessary refactorings while converting all tests to PHPUnit in #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase).
But yes, this probably also includes completely removing simpletest module in the end. And another consequence will be the removal of run-tests.sh.
Comment #6
benjy CreditAttribution: benjy at PreviousNext commented-1 for this been 8.x, I still find the Simpletest UI better than the verbose output for BTB which doesn't work with PHPStorm.
Comment #7
dawehnerThere is an alternative approach since a while: #2566767: Don't allow running phpunit-based tests via the UI which could be used as a way to educate more people.
Comment #8
timmillwoodI use the UI when Xdebug sometimes doesn't want to play ball, or if doing a webtest and what the vebose browser output, but I'd be fine to install it from contrib for that. No need to ship it with core.
Comment #9
jibranFor debugging you can use https://github.com/mglaman/intellij-drupal-run-tests.
Comment #10
dawehnerWell, that sounds like a problem of your xdebug configuration :)
Comment #11
mccrodp CreditAttribution: mccrodp at X-Team commentedRE: #8 Had that problem a while ago, for me it was that the command line was using a different php version than my dev env through the browser. I just ran
php --ini
and had to add the XDebug conf to the php.ini (incl xdebug.so) that the command line was using.+1 For this, with the UI remaining in contrib :)
Comment #12
sun+1 Removing Simpletest has always been the goal of my efforts.
Maintaining it takes too much time. Time that is much better spent with creating or contributing a GUI for phpunit.
For the same reasons I don't think the module would live long in contrib, as there are few people capable of maintaining it, but those will spend their time with more pleasing efforts.
Comment #13
Mile23At the moment, core needs improvements for any test runner:
Once we've done all that for run-tests.sh, we will have also done it for simpletest UI. It's not that we necessarily need simpletest UI, it's that if we fix simpletest UI for-realsies we'll have a better testing system overall.
Basically: Abandoning simpletest UI is the same as being afraid to look under the sofa cushions for fear of what you'll find. This question of doing away with the UI is a bikeshed question which avoids the reality that once we remove the UI, the testing system will still be a mess.
It's not that scary. :-) We can also make it less scary, and thus easier to maintain.
Comment #14
klausiI haven't looked into how DrupalCI would run phpunit, but I assume that is a solved problem because many people use Jenkins with phpunit, right?
My hope is to just convert everything to PHPUnit and then remove run-tests.sh, because it does not make sense to keep it? So hopefully we can throw out the sofa with the monsters under it without having to refactor or think about it.
Comment #15
dawehnerWell one problem we seem to have is that phpunit doesn't deal with fatals. I think some kind of wrapper script would be great for that, but its something we just need for the testbot and not on each other's local machines.
Comment #16
dawehnerI started to explore as alternative: https://github.com/VisualPHPUnit/VisualPHPUnit
One issue: https://github.com/VisualPHPUnit/VisualPHPUnit/issues/156
Comment #17
mpdonadioNeutral to -1 on this.
As an old-fart developer who learned how to do things before real debuggers became prevalent, I am much quicker with short debug statements going to output rather using xdebug inside phpstorm. Just having the xdebug enabled also slows down php noticeably, which makes a difference with integration tests.
I also find it quicker to incrementally build long test integration test sequences from verbose HTML output (yes, I know you can get this from run-test.sh, but I think the experience is better when run from the UI).
Comment #18
dawehnerWell, there is no reason against keeping
--browser
which does exactly the usecase you describe. It shows you the verbose output you need.Comment #19
Mile23No, actually, this issue says
--browser
isn't worth maintaining because it's the same code that's apparently not worth maintaining in the in-site UI.Comment #20
fgmFWIW, on 8.x-2.x these days, I can't even run tests based on Drupal\KernelTests\KernelTestBase in the UI: they fail before starting with errors like the one below, although they work just fine from the CLI:
Drupal\KernelTests\Core\Entity\RouteProviderTest::testHtmlRoutes PHPUnit_Framework_Exception: sh: 1: : Permission denied
Comment #21
dawehnerYeah, creating an issue for that is fine. But yeah things like that are IMHO an argument that its not worth to maintain it. It comes with cost and not that high benefit. Of course we would have to figure out how to get some better verbose message into BTB, but this is kind of an independent problem.
Comment #22
klausiYes, we need to make it crystal clear that running PHPUnit from Simpletest UI is broken and not supported. See also #2566767: Don't allow running phpunit-based tests via the UI.
Comment #23
benjy CreditAttribution: benjy at PreviousNext commentedI guess that depends who you're talking about. I've used the UI for the last 5 years building contrib modules and work projects with D7, I used it throughout the D8 release cycle until all Migrate tests were ported to KTB then I moved to storm. I've not done any D8 work yet, but it is disappointing for me that the UI will be removed.
I'm prepared to help out with maintaining the UI, I would have no doubt fixed the issues reported here once I started using D8 in my day job and wanted to use the UI. Alternatively, i'd be open to look at bringing an existing UI into core such as https://github.com/VisualPHPUnit/VisualPHPUnit if that was a more viable option.
Comment #24
dawehnerRight, this would remove our requirement to maintain it. Note: Its not directly usable, see https://github.com/VisualPHPUnit/VisualPHPUnit/pull/157 for example.
Would it be disappointing if we provide/there are alternatives for everything simpletest provides? Your comment sounds a bit nostalgic to be honest.
Comment #25
benjy CreditAttribution: benjy at PreviousNext commentedI've not tried it, would it be a suitable replacement even with that issue fixed. I think key parts of the current UI is an easy way to find tests and the ability to select and run multiple tests, or a whole modules tests etc.
Sure a bit of nostalgia for something I've enjoyed using, what's wrong with that? ;) But seriously, if we have the equivalent functionality then i'd be fine with that, this is why I mentioned helping out. I actually wonder whether a better CLI interface could be enough.
Comment #26
Fabianx CreditAttribution: Fabianx as a volunteer and at Tag1 Consulting commented#14: Before you can remove run-tests.sh you will need to create / install / test a parallel version of phpunit instead. The test runner relies on strong parallelism (concurrency = 32).
#12: What I can see is that the main work we do is completely independent from Simpletest anyway:
- Setting up the tests
- Our various test bases, etc.
and that won't change.
I think the only simpletest remnants are the DB table used for storing test results (and the format), which does not feel that hard for me to maintain.
run-tests.sh also is very independent of simpletest. It just creates a test class and runs it. There really is not much magic to that.
The same is true for the Simpletest UI.
Comment #27
dawehnerCan we please ensure to not derail the issue for that? This issue is for the simpletest UI :) Btw. there are parallel test runners we could at least evalulate, like https://github.com/brianium/paratest
Well, we had to put for example quite some effort to scale the simpletest UI to actually work with the amount of tests in D8.
Comment #28
Mile23Simpletest module does the following:
The reason we hate simpletest is because there are two supported test runners.
_simpletest_batch_operation()
for instance duplicates a great deal of code fromrun-tests.sh
. Stuff like that.I've worked on trying to refactor it so that it's maintainable and only a small fraction of my effort has been committed or even really reviewed, which is why I really find it hard to be motivated to continue. It seems to be the same for everyone else who takes this on. Everyone seems to think that the testing system is voodoo rocket science, but it's not. It's just unmaintainable.
The point here is not that the simpletest UI itself is unmaintainable, the point is that the testing system is unmaintainable, and the reluctance to keep the UI is a symptom, rather than a cause. That's why I called it a bikeshed in #13.
What should happen:
simpletest_*()
should be refactored into this library.core/tests/
. Its Composer dependencies should be require-dev.Who's ready to roll up your sleeves? Any takers?
Comment #29
jhodgdonI just happened to notice this issue.
Assuming that you mean in this issue "remove the ability to run tests whose output looks like SimpleTest UI does now", I am about -10000 on removing the Simpletest UI.
When I am developing tests for a contrib module, I use the UI a lot. It is just plain handy when you are writing tests for the UI of a module, and debugging the test itself. When you are trying to figure out if you have a UI bug or a test bug, you need to look at the verbose output, and having it right there in the browser is very handy. You can scroll down the list of assertions, find the red ones, and see what was going on just above it to debug your tests. I really really really do not want to lose that ability.
Also, in the User Guide project, I am using a browser-based test, with special verbose output, and a browser script to automate making screenshots for the different language versions of the User Guide. Without the Simpletest UI, I would not be able to do this automation, or would have to figure out a different way to do it. I really do not want to lose that!
Comment #30
dawehnerHint,
--browser
is your friend.Comment #31
jhodgdonIt would really help if the run-tests script had some documentation at the top. At least to say "To learn how to run this script, use the command "php run-tests.sh --help".
I will try --browser --verbose and see if it works for my use cases. Thanks!
Comment #32
jhodgdonYou might also put something about --browser --verbose into the issue summary, to avoid alarming random folks who come across this issue and say NO!!!! ;)
Comment #33
dawehnerComment #34
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedI find --browser to be awkward because it's not contained to a single window. Tests often take a long time to run so when I run them I tend to go off and do something else, then come back later to view the results. With the --browser option, whatever else I'm doing gets interrupted by a random browser window popping up when the tests are finished.
That's surely possible to improve (it could be a clickable link rather than automatically opening a browser window), but there are other benefits to having a UI as well: easier to find specific tests to run, generally easier to use, etc.
The comment from @Mile23 in #28 also makes a lot of sense to me.
Comment #35
jhodgdonOh. Yeah, if --browser puts up random links all the time into my browser, that would be totally lame. That would definitely not work well for me.
Ideally, what would happen is that at the end of the test, it would put up a page just like the test output currently in the Simpletest UI, which would let you see which assertions passed and failed, and have *links* to the verbose output.
Comment #36
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedWell, I think that is mostly what it does - it's just that even that one popup (at the end of the test run) is annoying to me because it occurs at a random time.
But that is something which is possible to improve.
Comment #37
jhodgdonI probably better try it before commenting any more. ;)
+1 to #28 too.
Comment #38
jhodgdon--browser is NOT working for me.
First I tried a command like this, from my test site's document root:
After waiting 23 minutes for my test to finish (this is the test that automates the screenshots for the user guide, and it takes a while to run on this machine), it came back with 5711 exceptions due to not having permissions to create directories for the output (even though I had chmod'd the directory).
So I tried the same, prefixed by sudo. This resulted in errors too, because root does not own my Firefox process:
So. I am back to using the Simpletest UI, unless someone has an idea of how to actually make this work.
Comment #40
daffie CreditAttribution: daffie commented+1 for #28
Comment #41
joachim CreditAttribution: joachim at Torchbox commentedSame here, +1 to #28.
If we have a decent, maintainable test running system, then a Simpletest module that's just a form that runs shouldn't be a big deal.
And it's important to keep the barriers low to people writing and running tests.
Comment #42
Mile23Looks like a bit of consensus on #28. If someone wants to make a meta for it and get the proverbial ball rolling, we can get going. Like I say: I've tried to go down this road a few times to roaring silence so if someone else could at least file the issue please. And maybe even review those issues linked in #13. Or even this one: #2780093: Have simpletest, run-tests.sh enforce their dependency on PHPUnit
Otherwise, sure. Make simpletest go away without replacing it. :-)
Comment #43
jhodgdonYeah, if --browser --verbose actually worked, that would be a replacement... but at least for me, it doesn't. Now, I could probably make a workaround, but it's MUCH nicer to use something that actually works, instead of having to do battle with the test system when you're already doing battle with the code you are trying to debug...
Comment #44
neclimdulYeah, that's basically the experience I've had with simpletest for 8 years. Its so bad I've got wrapper scripts with half a dozen shortcuts and gotcha's. If your httpd is down its even slower and worse because it sits there timing out waiting for the response and you have to wait for it to finish to get a reason it failed. Like a _single_ test will take 30min. You should try using phpunit's runner. Despite lacking concurrency its a dream in comparison. You mostly need --browser because run-tests's output is useless but phpunit's is readable and provides great feedback.
Comment #45
Mile23We'll have run-tests.sh until we finish #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase), and even then we still need it so we can do concurrency and handle PHPUnit fatals.
Comment #46
chx CreditAttribution: chx at Smartsheet, Migrate Rocks commentedy'all should ping webchick on this before doing it
Comment #47
jhodgdonSo, again: As far as I can tell, there is not really a viable alternative to running the tests in the browser, if you want verbose output. I could not get it to work from the command line.
This is *very* useful for debugging. I do not think we should just get rid of the ability to run tests and see the output line by line with the verbose HTML output. What is the plan to replace this functionality?
Comment #48
klausiVerbose output is being implemented in #2763401: PHPunit browser tests should log all Mink requests.
Comment #49
cilefen CreditAttribution: cilefen commentedComment #50
jhodgdonThat sounds good, but I still had various permissions problem using --verbose --browser, as suggested in the issue summary as a replacement for the Simpletest UI. My tests *are* using DrupalGet anyway. See #38.
Comment #51
klausiSee https://www.drupal.org/node/2116263 for how to run phpunit tests and enable browser output. Permission problems indicate that you are running phpunit as the wrong user. To which system user does the Drupal git checkout belong? Are you sure that it is the same user as the one running the test? I recommend https://klau.si/dev to run everything under your own user account for development.
Comment #52
dawehnerThis user problem is also documented in
core/tests/README.md
Comment #53
jhodgdonThe problem is that to do --verbose, it needs to run as the web user or root user. But to do --browser, it needs to be me, because I am the owner of the browser process.
Comment #54
klausiAlso make sure to fill out your copy of phpunit.xml for printerClass and BROWSERTEST_OUTPUT_DIRECTORY as described on https://www.drupal.org/node/2116263
Comment #55
dawehner@jhodgdon
The problem is that to do --verbose, it needs to run as the web user or root user. But to do --browser, it needs to be me, because I am the owner of the browser process.
Doesn't it print out the URL you could open up manually as well? In case it doesn't we should print it out :)
Comment #56
klausiTo print out the URL you need to set printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter" in your phpunit.xml.
Comment #57
jhodgdonWell, as-is, --browser and --verbose do not work together, and there is no documentation of all of this stuff (or even a link to where the documentation lives) in the script itself. I would not say that we actually have a viable replacement for the Simpletest UI until --browser --verbose Just Works, or at least has a documented path (documented in the script) to making it work.
Anyway... I think I also saw another issue about removing the script too? This all just seems to me to be moving in the wrong direction.
Comment #58
klausiWhat script do you mean? run-tests.sh?
Yes, run-tests.sh will be removed in the end because phpunit will be our test runner. "--browser" is not really needed, if you setup your phpunit.xml as the documentation says at https://www.drupal.org/node/2116263 . Then you will get nicely printed links to the static HTML generated, which you can open in your browsers and navigate in between as you did with Simpletest.
Comment #59
jhodgdonWell, then the issue summary here is outdated and needs clarification.
Comment #60
dawehnerWell, people mix up different things here. IMHO we have a couple of things at the same time
* Provide a script to run tests (run-tests.sh)
* Leverage the phpunit test script (phpunit)
* Provide a UI to show which tests are available
* Provide a UI to show the result of the test run
This issue is really JUST about point 3)
Comment #61
jhodgdonOK, fair enough. But if we get rid of Simpletest UI, we are removing access to all 4 points from the UI. So are there issues about the other 3?
For myself... I personally don't care much whether I have to know the name of the test class and/or run from the command line, so I don't care as much about points 1-3. But I do care about point 4... and I think just getting rid of it is not necessarily the best idea. My reasoning:
a) I have found it quite useful to see the verbose output of every drupalGet in tests as I am debugging them. It's convenient to be able to run a test, see the output, click on Verbose where it is supposed to be doing something and see what it did instead, fix the test or the code, run it again, etc. I like the UI for that. Getting rid of it is not so great.
b) I'm using the verbose output, in the browser, to generate automated screenshots for the User Guide... my fear is that by eliminating WebTestBase and the Simpletest UI, I will lose the ability to make automated screenshots, or I will have to completely re-engineer it. It was not too easy to set up in the first place.
Comment #62
joachim CreditAttribution: joachim at Torchbox commentedI really worry about how this will raise the hurdle for running tests. We want people to run tests, and we want people to write tests, which entails running them. If we want them to do this, then we want as few barriers as possible in their way. People will only keep trying past so many failures before they quit something.
If we remove this UI (and I don't think we should -- see #28 above), then the script for running this from the command line needs to be *as simple as or simpler than* going to a webpage and ticking boxes for the tests you want to run.
run-tests.sh is horrible (incorrectly named for starters) -- for example, it falls over when options are in the wrong order:
... and that ran, but showed me a URL that was a 404... :/
EDIT: removed complaint about the output -- was due to absence of --url parameter, same as the 404. Which is still extra faff to have to bother with.
Comment #63
mpdonadioDo we have a sense about how many people use the test UI https://simplytest.me/ when evaluating patches?
Comment #64
jhodgdon@mpdonadio -- ... um... is that relevant to this discussion? simplytest.me allows you to easily spin up a site with your patch attached. This is about Simpletest UI (admin/config/development/testing) within a Drupal site to run the automated tests.
Comment #65
joachim CreditAttribution: joachim at Torchbox commentedYup, once a patch is uploaded to d.org, the test runner does a great job! :)
This is about making sure that people feel able to write tests for their own patches. To write tests, you need to run them locally (or spam d.org with each new attempt... which is not ideal).
Comment #66
mpdonadio#64, you can spin up a site with a patch, and then use that to run tests from Simpletest UI with the patch applied. I frequently use simplytest.me for project reviews so I don't have to disturb my own local dev sites, but I don't know how many people use it to manually test modules / patches and also run tests from the UI. I have done this a handful of times when I don't want to disturb a local dev site.
Comment #67
Mile23OK, so we have some complaints about run-tests.sh. I'd suggest that if anyone wants to improve run-tests.sh, they should open an issue so we can work on it. Use this as a parent if you'd like, but at least file the issue: #2626986: [meta] Improvements to run-tests.sh
Comment #68
joachim CreditAttribution: joachim at Torchbox commentedThere are already issues for the run-tests script, including one to change the file name to something sane, and one to use 'env' in the shebang line so it runs with Php on any system. I seem to remember they have been sitting at needs review for a while...
Edit: ah, I see that's already on that meta issue.
Comment #69
fgmFWIW we don't have automatic test running on security patches so it's necessary to run them locally.
Comment #70
dawehner@fgm
Please read the issue title, this is not about removing the capability to run tests.
Comment #71
fgm@dawehner indeed: but what I mean is without the graphical runner it is much harder to debug tests since the --browser option to run-tests.sh does not open a browser to the debug output nor, more importantly, provide the URL at which it might be available.
Comment #72
klausiBefore removing the Simpletest UI we will convert all tests to phpunit. Please don't run phpunit tests with run-tests.sh, as it has quite a few problems. See https://www.drupal.org/node/2116263 on how to run phpunit tests with debug output, browser windows and all bells and whistles.
Comment #73
fgmThis is what I did initially, since I've been following the present issue since it started. However it turned out the steps outline on [#2116263] just don't provide a way to access the output. The results are kept in a table with thousands of rows, each containing a URL, and no visible way to know which of the rows contains the useful information. Of course, --browser just does nothing (macOS). Plus, the phpunit concurrency is not yet there (yes I know about paratest).
So, since the same page suggests further down to go back to run-tests, that's what I did. But same problem: no usable debug output. The files are there, but no way to related them with the actually failing steps information.
So in the end, it had to be back to the UI.
Hopefully, I missed something, because I would very much prefer to be able to run tests from the CLI if only I could get an easily browsable report, even if it had to be in text format. Any idea ?
Comment #74
Berdir--browser should work fine, you are supposed to get a page just like right now with the results, only difference is that you don't select and run tests in the browser, you just look at the results there. I know many people who use it on OSX, maybe you need to configure something, have a look at the code in run-test.sh to see what it executes exactly. Make sure you provide --url as well.
Comment #75
klausiDid you copy phpunit.xml.dist to phunit.xml and set printerClass and BROWSERTEST_OUTPUT_DIRECTORY? Then the output will look something like this:
This is also explained at the phpunit browser test tutorial https://www.drupal.org/node/2783189
Comment #76
jhodgdonRE #72...
That is very Core-centric. People have written tests for Contrib modules as well, and they may not all be converted... contrib modules do not necessarily follow all the changes happening in Core or keep up with them. We should encourage contrib module maintainers to write and run tests, not put up barriers to them doing this.
Comment #77
joachim CreditAttribution: joachim as a volunteer commented> Did you copy phpunit.xml.dist to phunit.xml and set printerClass and BROWSERTEST_OUTPUT_DIRECTORY?
And that's a good example of why we DO want to keep a graphical test runner: because it's simple.
I think this issue should be closed, and replacements opened. Its premises are flawed.
> Remove Simpletest UI because we don't want to maintain a graphical test runner
It's not that we don't want to maintain a *graphical* test runner, but that we don't want to maintain *more than one* test runner. And ideally, we want to maintain *no* test runner.
We *do want* a UI for running tests because the barrier to writing (and therefore running) tests should be as low as possible. There shouldn't be configuration to set up. There shouldn't be command-line options that you can get in the wrong order, or that cause unclear failures if you get them wrong. A graphical UI allows users to pick the tests they want to run from a list, and click a button and *just run the test*.
So what we should be doing is reworking Simpletest UI so that it's a front-end for the test runner we don't maintain.
Comment #78
Mile23SimpleTest is with us until D9 if not longer, because of the way deprecation works in the core process.
For instance, here's an issue which does some cleanup in simpletest: #2801817: Inject services into SimpletestTestForm and functional cleanup for the test_discovery service Note that it deprecates the
simpletest_test_get_all()
function for removal before D9. No doubt a maintainer will push back on even that. :-)Right on.
Comment #79
dawehner@fgm
What you describe is really simply a bug. Do you mind opening up an issue?
--browser
works really fine for many people.Comment #80
Fabianx CreditAttribution: Fabianx as a volunteer and at Tag1 Consulting commentedI also think and suggest we postpone this until D9 is closer.
It might be that everyone is so happy with the new test system that this becomes a non-issue anyway. :)
Comment #81
klausiHello Simpletest UI fans, we are currently improving the bare minimum when running PHPUnit tests from the Testing UI in #2809117: Integrate PHPUnit verbose output in Simpletest UI. Can any of you take a look and run a failing version of ColorSafePreviewTest for example?
Comment #82
catchThe simpletest APIs are with us until Drupal 9.
UIs aren't an API, so moving this back to 8.3.x (but leaving postponed - a command-line-command generator from test groups and similar would be useful).
Comment #83
jhodgdonIf we had a viable command-line test runner that (with as little setup as "Install the Simpletest module") would allow people to run tests and get verbose output that was very similar to the Simpletest UI, I doubt anyone would complain too much. People who write tests and want to run tests can probably handle the command line, if it's as simple as "run this command with these options" and it Just Works (TM).
The problem is that, as much as people here advocating for getting rid of Simpletest UI keep saying this exists, in practice the replacement doesn't exist, or at least doesn't work for everyone, and also the hacks you may need to use to get it working aren't documented.
Comment #84
klausiNot sure about what hacks you are talking about because https://www.drupal.org/docs/8/phpunit and https://www.drupal.org/docs/8/phpunit/running-phpunit-tests and https://www.drupal.org/docs/8/phpunit/phpunit-browser-test-tutorial are there.
But if you are just interested in one command here you go:
Of course that is horribly long and tedious to remember, that's why we politely ask you to set up phpunit.xml at https://www.drupal.org/docs/8/phpunit/running-phpunit-tests
Let me know what hacks you think are not documented and then let's write them down!
Comment #85
jhodgdonI was not able to get --browser and --verbose to work for me. See #38.
Comment #86
jhodgdonOh. I was trying the run tests .sh script. Anyway, at the moment I am using WebTestBase still, not phpUnit.
Comment #87
jhodgdonAnd I realize you are trying to get rid of WebTestBase in Core at the moment. But not everyone is a Core developer, and asking all of Contrib to update all of their tests at the moment is a lot to ask. IMO the effort to get rid of the simpletest UI at this point is not friendly to Contrib, because all we'll be left with to run WebTestBase tests at that point is the terribly flawed run tests .sh script.
Comment #88
BerdirWe are working on stop using WebTestBase, that's not the same as removing it. That won't happen before 9.x. But it will definitely happen then. So sooner or later, you will have to convert anyway. But I'm waiting with my own modules as well, until a large amount of core has been converted so that the necessary API's and tools are there and the remaining issues are fixed. Nothing wrong with that.
--verbose and --browser works fine for many people with run-tests.sh for old web tests.. As it has been said before, if it doesn't work for you, then *please* create a bug report, provide infos about your system, how exactly you call it and any other information that might be useful (installed browsers and so on).
Trust me, it is worth the effort. It's just so much faster to use, you can easily run single methods, works very well in combation with the Copy Reference method in phpstorm (both methods and classes), you can easily run groups, you can run tests in parallel which makes them 2x, 3x... 8x faster depending on how many CPU's you have. And the output of the results with --browser is *exactly* the same as when using the UI to run tests.
Comment #89
jhodgdonI didn't make a bug report about the runtests script because after I posted #38, I was basically told "you did it wrong" and "besides, we don't want to support runtests either", so I gave up. I could probably get it to work, but since I have simpletest UI and it works, it was not worth the effort for me.
The report is there in #38 if anyone actually cares about this. But I don't get the impression that anyone wants to keep maintaining the run tests script any more than they want to maintain the simpletest UI.
Comment #90
BerdirI see. You should not sudo as root, you should sudo -u apache-user. Which is usually www-data. But I guess that won't solve that problem. I turned the whole thing around and I configured apache to run as my user on my local system and then you don't need to mess with sudo. There is only one downside to that, and that that's drupal then always removes write permissions to sites/default but that can actually be disabled now as well.
According to some googling, http://askubuntu.com/questions/325274/why-do-i-get-ibus-warning-on-runni... and https://bugs.launchpad.net/ubuntu/+source/ibus/+bug/1125944 say you should use gksudo. But that's only a warning anyway and shouldn't actually break anything.
While nobody likes maintaining run-tests.sh, it's going to be around until we remove simpletest (not the UI, the whole thing). so not before 9.x. I use it daily.
Comment #91
fgmOh @berdir, how do you disable Drupal removing write permissions to sites/default ?
Comment #92
BerdirSee example.settings.local.php, documented there.
Comment #93
fgmThanks, I hadn't understood this was what this setting was about. ($settings['skip_permissions_hardening'] = TRUE;)
Comment #94
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedFound a small documentation issue. see #2811065: Fix docs around --printer option in phpunit.xml.dist
Comment #95
fgmJust noticed this other approach to parallel tests, (not paratest): https://github.com/jwage/phpchunkit
Comment #96
joachim CreditAttribution: joachim as a volunteer commented> we don't want to maintain a graphical test runner
Here's my use case why we DO:
Tonight, I saw that one of the tests on Flag module is failing.
But it's 10pm, I've just had a dreadful evening putting the toddler to bed and I want to relax and watch TV. I figure, hey, I can run the test on my laptop at the same time, see if it's an easy fix.
Except I haven't run a test on the CLI in over a month. So I've forgotten the syntax for it. I remember I have to specify the class... but do I have to escape the namespace separators? What about the option to get output? What about the URL option? Where are the docs? What's the option to get the help output?
... and there are too many hurdles. If it weren't for the GUI test runner, I would give up and leave the problem for someone else or for another day.
Comment #97
klausiOh cool, we are sharing stories here?
I just spent ~20 hours tracking down a random test fail in #2770921: Feb 21st: Convert chunk of WTB to BTB by just moving classes, changing use statements adding traits leading to the fix in #2820442: SimpleTestBrowserTest has random fails when BrowserTestBaseTest gets larger. And we haven't even figured out completely yet why we have that random test fail, so the underlying root cause is still unresolved. Yay Simpletest testing the Simplest UI running PHPUnit inception hell!
Would it be enough for you if we just display a phpunit command in the Testing UI that you can copy paste to your terminal when you filter for flag tests in the UI?
Comment #98
Mile23To be fair:
SimpleTestBrowserTest
is a bad test for exactly this reason. It's unmaintainable. It's not a good test.The reason we have it is because we made all the testing code untestable back 10 years ago or whatever and for some reason refuse to work on it, so that tests like
SimpleTestBrowserTest
have to do the test-ception crap.The resaon it's still like that is because any time anyone tries to maintain it, they're met with total apathy (at best). That's my user story.
See #28, where we can talk about making the testing system less brittle overall for all uses, thus improving the DX for everybody, make components of the testing system more testable, and, basically replace
SimpleTestBrowserTest
with some tests that make sense.#2641632: Refactor simpletest's *_phpunit_*() (and junit) functions etc. to a class, deprecate
#2800267: Turn simpletest_clean*() functions into a helper class
#2624926: Refactor run-tests.sh for Console component.
etc.
Comment #99
pfrenssenYou can put a
phpunit.xml
file in the root of your project that contains your config, and then you can simply run this:Doesn't get simpler than that :)
I can recommend to simply never type out the options on the command line, the very first time you want to run a test, just create the
phpunit.xml
file and you never have to think about it again.You can even have it automatically generated when you start a new Drupal 8 project based on my drupal-project fork.
Comment #100
joachim CreditAttribution: joachim as a volunteer commented@klausi I'm not saying it's not a bit lazy of me. But I was trying to illustrate the point that users are lazy, and that they give up at hurdles, even when they want the end goal. (It's why commerce sites don't make you create an account, they just create it for you in the background, because being asked to make a username and password makes too many users give up, even though they want to buy the thing in their cart.)
I think that one of the main purposes of having a test runner is so that core and contrib contributors can run tests, so that they can write and work on tests.
Given that goal, we need to keep the hurdles to that as low as possible.
Nothing is going to be as simple as selecting a checkbox is a GUI.
Comment #101
joachim CreditAttribution: joachim as a volunteer commentedPS. The end of my user story is that I ran the GUI tests, found the bug, and fixed it. Took about 30 minutes. But if if it hadn't been for the GUI, I'd have given up and left it for someone else to fix.
That would have been 30 minutes lost to the Drupal community. Now think of those 30 minutes, and multiply them by everyone we'd like to be able to run tests.
We should definitely make it easier to maintain the GUI test runner, but maintaining a GUI test runner is an *investment*.
Comment #102
catch@joachim if the GUI test runner had given you the phpunit command line snippet to run, would that have helped? It could also create the phpunit.xml file to download or copy and paste. That way it'd save looking up the cli options or phpunit.xml structure even the first time tests are run. It's still slightly more work than running tests in the UI, but a lot less than figuring out running tests from cli the first time (or after a while) from docs.
Comment #103
joachim CreditAttribution: joachim as a volunteer commentedA GUI that produces the command line snippet would definitely be better than no GUI at all, yes.
Comment #105
kevinquillen CreditAttribution: kevinquillen at Velir commentedI agree with the removal or at least improving it to give you the command you need to run. I spent a decent amount of hours last week tracking down an error that the UI gave to me which had no real bearing on the actual issue. I can only imagine how many other people are led down the same path, which is just as discouraging to writing tests as getting the command line argument order wrong. Not to be dismissive of the time put into creating and maintaining the Simpletest UI, but it isn't the first time it has happened to me, either.
For those using PHPStorm, Matt Glaman created a plugin to ease the creation and running of tests from PHPStorm itself. It currently has some bugs in different versions of PHPStorm (I am a couple versions behind on ver 10 so it might just be me). So that is an option for those folks using the IDE too.
Comment #106
Mile23Made an issue which is basically comment #28. If you thought that was a good idea, please poke your head in on #2866082: [Plan] Roadmap for Simpletest
Comment #109
DamienMcKennaThis is up there with requiring composer that will drive beginners and less technical users away. I'm 100% behind refactoring and reducing the custom functionality of the UI so it can be more streamlined, but to help adoption, help beginners and not throw a huge roadblock in front of folks who haven't mastered the intricacies of their OS's terminal system, we should not assume everyone is going to have a $200+ commercial IDE to avoid their daily dose of terminal anxiety.
Comment #110
Mile23So we can look forward to reviews of the issues on #2215035: [meta] Simpletest UI cleanups right? :-)
We just did this #2893117: Improve HTML caching of Simpletest UI test form which improves HTML caching for the test runner UI.
Want to improve the Simpletest UI? Review #2296615: Accurately support multiple @groups per test class so we can move on to #2858652: Support multiple @group test annotations in Simpletest UI
There's also #2301481: Mark test groups as belonging to modules in UI which has been sitting for a while.
And then this one, which wants to deprecate the batch-based test runner which is the one that the Simpletest UI uses, because no one wants to maintain three different test runners all of which have different requirements. Should the runner used by Simpletest UI be deprecated? #2748967: Trigger E_USER_DEPRECATED for BC support in simpletest_run_tests()
Comment #112
Mile23So in the past year, not much motion on all those UI-related issues in #110. So I think it's fair to say that even if people want to use this UI form, no one is interested in supporting it.
Therefore, in the interest of graceful deprecation, we should have a follow-up to put some text on the UI that warns users that it's going away in Drupal 9, and also deprecates all the functions that only the UI touches. When that's in, we can un-postpone here.
Comment #113
Gábor HojtsyIn #3028663: Split up simpletest into simpletest and testing_ui to enable easier decisions for Drupal 9 I made multiple attempts to get the answer to the following question: what is the (existing) testing UI useful for once all tests are phpunit? This is not explained in this issue either (why it becomes bad once 90% of tests are phpunit?). This is what the summary says now:
It does not explain what changes at 90%. I would add the "Needs issue summary update" tag if it would not already be on the issue.
Comment #114
jhodgdonI know that no one wants to support the SimpleTest UI, but the User Guide project is currently using the SimpleTest base classes and UI in its process that makes/updates automated screenshot images for all of our translation languages whenever new versions of Drupal come out. I tried at one point in the past to convert this process to use JavascriptTestBase (which in theory has the capability of making screenshots), but at the time, there were so many bugs that I gave up. That was a while back, and the JavascriptTestBase class and JS testing system has since had its guts ripped out and has been revamped and rewritten, and it's possible I could get it to work now, but I'm not sure. The User Guide's needs are a bit unique, since the purpose is both to test the UI text that is referenced in the User Guide, and to produce cropped-down screenshots, and the tests/images have to be done in multiple languages.
I guess my path forward could just be to grab the Simpletest base and classes and UI code and put them into the User Guide project when they go away from Core. Or it could be I could convert to JavascriptTestBase -- have all the Core tests successfully been converted that use JS, or are there still bugs? Are there any multilingual JS tests in Core? Any advice/thoughts?
Comment #115
Mile23@jhodgdon: Are there any issues in the user guide project that people could help out on to get a solution for that that doesn't tie us to the simpletest UI? I found #3029816: Convert screenshot automation to WebDriverTestBase are there any others?
Comment #116
jhodgdon@Mile23 - that is the issue. I just created that today after discussing with a few people in Slack about the new-ish WebDriverTestBase class. The last time I tried to convert (to JavascriptTestBase), the log of what happened and why I abandoned the effort is in the related issue:
#2856747: Convert screenshot automation to JavascriptTestBase
If you or anyone else is interested in helping out... there is quite a bit of documentation about the current screenshot process in a README file in this directory:
https://cgit.drupalcode.org/user_guide/tree/auto_screenshots
The current test classes are in the src/Tests directory under there. There is a base class, and then subclasses for each language.
Comment #117
catchMoving this back to 8.x. If we want to remove the SimpleTest UI, we can do so in 8.x - there's no bc issue because it's purely a user interface with no data to migrate, the replacement is using the CLI. Whether we want to completely remove it or not is a different question but one that is version agnostic.
Comment #118
DamienMcKennaimho we should postpone this for now until the code is refactored a bit in #3028663: Split up simpletest into simpletest and testing_ui to enable easier decisions for Drupal 9.
Comment #119
jhodgdonI was able to get rid of the need for anything Simpletest-related in the User Guide tests. I am no longer needing the test running UI or the Simpletest base classes. So... anything I objected to before, you can ignore. :)
Comment #120
larowlanAwesome! Great work
Comment #122
xjmComment #123
xjmSo:
For me, this is OK so long as (a) the test runner UI exists in contrib and (b) the command-line script in core still presents the links to the verbose output in the handy way it does currently.
Comment #125
catchWe ended up moving SimpleTest to contrib, so marking as outdated.