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

klausi created an issue. See original summary.

klausi’s picture

I was quite bold with the issue summary, feel free to edit and correct!

larowlan’s picture

I'm +1 for this, there are graphical runners for phpunit, and most are using phpstorm anyway.

Mile23’s picture

Removing 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.

klausi’s picture

We 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.

benjy’s picture

-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.

dawehner’s picture

There 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.

timmillwood’s picture

I 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.

jibran’s picture

dawehner’s picture

Well, that sounds like a problem of your xdebug configuration :)

mccrodp’s picture

RE: #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 :)

sun’s picture

+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.

Mile23’s picture

At 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.

klausi’s picture

I 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.

dawehner’s picture

Well 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.

dawehner’s picture

mpdonadio’s picture

Neutral 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).

dawehner’s picture

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).

Well, there is no reason against keeping --browser which does exactly the usecase you describe. It shows you the verbose output you need.

Mile23’s picture

Well, there is no reason against keeping --browser which does exactly the usecase you describe. It shows you the verbose output you need.

No, 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.

fgm’s picture

FWIW, 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

dawehner’s picture

FWIW, 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

Yeah, 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.

klausi’s picture

Yes, 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.

benjy’s picture

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

I 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.

dawehner’s picture

. 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.

Right, this would remove our requirement to maintain it. Note: Its not directly usable, see https://github.com/VisualPHPUnit/VisualPHPUnit/pull/157 for example.

I've not done any D8 work yet, but it is disappointing for me that the UI will be removed.

Would it be disappointing if we provide/there are alternatives for everything simpletest provides? Your comment sounds a bit nostalgic to be honest.

benjy’s picture

I'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.

Would it be disappointing if we provide/there are alternatives for everything simpletest provides? Your comment sounds a bit nostalgic to be honest.

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.

Fabianx’s picture

#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.

dawehner’s picture

#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).

Can 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

The same is true for the Simpletest UI.

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.

Mile23’s picture

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.

Simpletest module does the following:

  • Provide the test runner code that run-tests.sh uses, both for simpletest-based tests and phpunit-based tests.
  • Provide the display that run-test.sh --browser uses (It's the same one that shows you results in the UI).
  • Map results between phpunit-based tests and the simpletest schema for both UI and run-tests.sh.
  • Basically serve as a repository of code for run-tests.sh.
  • Allows sites to disable in-site testing, even though they can still run the tests from run-tests.sh when it's not enabled (using --sqlite).

The reason we hate simpletest is because there are two supported test runners. _simpletest_batch_operation() for instance duplicates a great deal of code from run-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.module should be nothing but a page that lists tests and lets you run them. This would be super easy to make and maintain, because it's just a Drupal form with some internals glue.
  • Test runner code should be a library, similar to a Component or an external library. It should not have a dependency on anything else in Drupal. Any function that starts with simpletest_*() should be refactored into this library.
  • The test runner code should live under core/tests/. Its Composer dependencies should be require-dev.
  • There should only be one API to this library, and it should be designed so that each concurrent test run could also be a batch run.
  • run-tests.sh should be renamed so it's not embarassing.
  • run-tests.sh should be a proper console app so it can be maintained.

Who's ready to roll up your sleeves? Any takers?

jhodgdon’s picture

I 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!

dawehner’s picture

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.

Hint, --browser is your friend.

jhodgdon’s picture

It 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!

jhodgdon’s picture

You might also put something about --browser --verbose into the issue summary, to avoid alarming random folks who come across this issue and say NO!!!! ;)

dawehner’s picture

Issue summary: View changes
David_Rothstein’s picture

I 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.

jhodgdon’s picture

Oh. 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.

David_Rothstein’s picture

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.

Well, 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.

jhodgdon’s picture

I probably better try it before commenting any more. ;)

+1 to #28 too.

jhodgdon’s picture

--browser is NOT working for me.

First I tried a command like this, from my test site's document root:

php ./core/scripts/run-tests.sh  --color --verbose --browser --keep-results \
  --url [URL TO MY SITE] --class '[MY CLASS NAME]

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:

(firefox:17596): GLib-GObject-WARNING **: Attempt to add property GnomeProgram::sm-connect after class was initialised
...
(firefox:17596): IBUS-WARNING **: The owner of /home/jhodgdon/.config/ibus/bus is not root!

So. I am back to using the Simpletest UI, unless someone has an idea of how to actually make this work.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

daffie’s picture

+1 for #28

joachim’s picture

Same 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.

Mile23’s picture

Looks 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. :-)

jhodgdon’s picture

Yeah, 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...

neclimdul’s picture

Yeah, 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.

Mile23’s picture

We'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.

chx’s picture

y'all should ping webchick on this before doing it

jhodgdon’s picture

So, 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?

klausi’s picture

Verbose output is being implemented in #2763401: PHPunit browser tests should log all Mink requests.

cilefen’s picture

jhodgdon’s picture

That 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.

klausi’s picture

See 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.

dawehner’s picture

This user problem is also documented in core/tests/README.md

jhodgdon’s picture

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.

klausi’s picture

Also 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

dawehner’s picture

@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 :)

klausi’s picture

To print out the URL you need to set printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter" in your phpunit.xml.

jhodgdon’s picture

Well, 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.

klausi’s picture

What 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.

jhodgdon’s picture

Well, then the issue summary here is outdated and needs clarification.

dawehner’s picture

Well, 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)

jhodgdon’s picture

OK, 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.

joachim’s picture

I 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:

~/Sites/8-drupal joachim$ php core/scripts/run-tests.sh --verbose  --class 'Drupal\views_ui\Tests\PreviewTest' --browser
  ERROR: No valid tests were specified.
~/Sites/8-drupal joachim$ php core/scripts/run-tests.sh --verbose --browser  --class 'Drupal\views_ui\Tests\PreviewTest'

... 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.

mpdonadio’s picture

Do we have a sense about how many people use the test UI https://simplytest.me/ when evaluating patches?

jhodgdon’s picture

@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.

joachim’s picture

Yup, 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).

mpdonadio’s picture

#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.

Mile23’s picture

Issue tags: +Testing system

OK, 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

joachim’s picture

There 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.

fgm’s picture

FWIW we don't have automatic test running on security patches so it's necessary to run them locally.

dawehner’s picture

@fgm
Please read the issue title, this is not about removing the capability to run tests.

fgm’s picture

@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.

klausi’s picture

Before 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.

fgm’s picture

This 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 ?

Berdir’s picture

--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.

klausi’s picture

Did you copy phpunit.xml.dist to phunit.xml and set printerClass and BROWSERTEST_OUTPUT_DIRECTORY? Then the output will look something like this:

cd core
../vendor/bin/phpunit --filter testReactionRulePage ../modules/rules/tests/src/Functional/UiPageTest.php
PHPUnit 4.8.11 by Sebastian Bergmann and contributors.

.

Time: 25.14 seconds, Memory: 6.00Mb

OK (1 test, 5 assertions)

HTML output was generated
http://drupal-8.localhost/sites/simpletest/browser_output/Drupal_Tests_rules_Functional_UiPageTest-13-411368.html
http://drupal-8.localhost/sites/simpletest/browser_output/Drupal_Tests_rules_Functional_UiPageTest-14-411368.html
http://drupal-8.localhost/sites/simpletest/browser_output/Drupal_Tests_rules_Functional_UiPageTest-15-411368.html

This is also explained at the phpunit browser test tutorial https://www.drupal.org/node/2783189

jhodgdon’s picture

RE #72...

Before removing the Simpletest UI we will convert all tests to phpunit.

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.

joachim’s picture

> 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.

Mile23’s picture

Version: 8.3.x-dev » 9.x-dev

SimpleTest 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. :-)

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.

Right on.

dawehner’s picture

@fgm
What you describe is really simply a bug. Do you mind opening up an issue? --browser works really fine for many people.

Fabianx’s picture

Status: Active » Postponed

I 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. :)

klausi’s picture

Hello 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?

catch’s picture

Version: 9.x-dev » 8.3.x-dev

The 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).

jhodgdon’s picture

If 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.

klausi’s picture

Not 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:

export SIMPLETEST_BASE_URL=http://drupal-8.localhost; export BROWSERTEST_OUTPUT_DIRECTORY=sites/default/files; ./vendor/bin/phpunit -c core/ --printer '\Drupal\Tests\Listeners\HtmlOutputPrinter' core/modules/color/tests/src/Functional/ColorSafePreviewTest.php

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!

jhodgdon’s picture

I was not able to get --browser and --verbose to work for me. See #38.

jhodgdon’s picture

Oh. I was trying the run tests .sh script. Anyway, at the moment I am using WebTestBase still, not phpUnit.

jhodgdon’s picture

And 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.

Berdir’s picture

We 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.

jhodgdon’s picture

I 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.

Berdir’s picture

I 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.

fgm’s picture

Oh @berdir, how do you disable Drupal removing write permissions to sites/default ?

Berdir’s picture

See example.settings.local.php, documented there.

fgm’s picture

Thanks, I hadn't understood this was what this setting was about. ($settings['skip_permissions_hardening'] = TRUE;)

webflo’s picture

fgm’s picture

Just noticed this other approach to parallel tests, (not paratest): https://github.com/jwage/phpchunkit

joachim’s picture

> 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.

klausi’s picture

Oh 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?

Mile23’s picture

To 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.

pfrenssen’s picture

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?

You can put a phpunit.xml file in the root of your project that contains your config, and then you can simply run this:

$ ./vendor/bin/phpunit path/to/my/test.php

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.

joachim’s picture

@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.

joachim’s picture

PS. 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*.

catch’s picture

@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.

joachim’s picture

A GUI that produces the command line snippet would definitely be better than no GUI at all, yes.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

kevinquillen’s picture

I 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.

Mile23’s picture

Made 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

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

DamienMcKenna’s picture

This 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.

Mile23’s picture

So 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()

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Mile23’s picture

Version: 8.7.x-dev » 9.x-dev
Issue tags: +Needs followup

So 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.

Gábor Hojtsy’s picture

In #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:

Remove Simpletest's UI as soon as 90% of our test cases are converted to PHPUnit tests

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.

jhodgdon’s picture

I 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?

Mile23’s picture

@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?

jhodgdon’s picture

@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.

catch’s picture

Version: 9.x-dev » 8.7.x-dev
Status: Postponed » Active

Moving 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.

DamienMcKenna’s picture

jhodgdon’s picture

I 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. :)

larowlan’s picture

I was able to get rid of the need for anything Simpletest-related in the User Guide tests

Awesome! Great work

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

xjm’s picture

Priority: Normal » Major
Issue tags: +Needs product manager review, +Drupal 9
xjm’s picture

So:

  • We need an IS update here.
  • Once we have said IS update, we also need product manager signoff on this change since what is and isn't included in core needs product management signoff (as well as FM and RM signoff).

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.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

catch’s picture

Status: Postponed » Closed (outdated)

We ended up moving SimpleTest to contrib, so marking as outdated.