Problem/Motivation

This is in part a bug report, a documentation requires, and a rant.

I've been busy with other stuff the last few months, and am discovering that the grand mix of fixes and improvements mean I can no longer get a simple test run of the module to work.

And I'm a *$(R*& maintainer, supposedly.

My general opinion of many of these changes isn't exactly a secret. But since they've been done: documentation needs to get fixed to make these fixes and improvements actually fix or improve anything.

At a minimum, the following work is required:

  • What needs to get installed for set up MUST be documented. My sense is that it likely includes phantomjs (no, INSTALL.md does not suggest this). Some links to how phpunit.xml needs to get edited is also essential. If there's some other doohinky required, yeah, that too.
  • The EXACT call to run-tests.sh needed to test the module. INSTALL.md is vague, and points to links which do not answer this question.

My major criticism of the changes made to the test system was that the changes were very literally a waste of time. As in: it made testing modules more difficult for people working in contrib, and required more time to get less accomplished. Hopefully it saved time for the core folk, because if not: WTF???

I'm going to start going through this and see what needs to get changed. But if you folks already know, then it would be good if we get these docs in before we worry any more about coding standards etc.

Yeah, it's a rant. But admit it: IT'S A RIGHTEOUS RANT.

Proposed resolution

Add a d.o page about all the new testing stuff so that we can not lose our minds. Link to it from TESTING.md.

Remaining tasks

Add testing example showing how to organize all the different types of tests.

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Torenware created an issue. See original summary.

Mile23’s picture

Issue summary: View changes

Rant on! :-)

The right place to document how to test a module (or project or whatever) would be at some d.o page where anyone who needs it can find it more easily, for any project.

TESTING.md links to https://www.drupal.org/node/645286 but there really should be a more specific how-to-test-your-d.o-project page.

The way to get around the phantomjs stuff is to either learn to use a local testbot (too much to ask, really, but it does set up phantomjs on a VM), or to use the --types argument to run-tests.sh, and include all the types except PHPUnit-FunctionalJavascript. You might ask: Where is the list of test types? The answer: There isn't a documented one, but there's the phpunit.xml.dist here: http://cgit.drupalcode.org/drupal/tree/core/phpunit.xml.dist

The PHPUnit test suites are: unit, kernel, functional, and functional-javascript. This means you can do ./vendor/bin/phpunit -c core/ --testsuite unit and run only unit tests without kernel, functional or js tests. Unfortunately you can't run all of them except one, so you can't just exclude the js tests. Also you can't run simpletest-based tests from PHPUnit.

You map these suites to run-tests.sh types by prepending PHPUnit-. So php ./core/scripts/run-tests.sh --types 'Simpletest,PHPUnit-Unit,PHPUnit-Kernel,PHPUnit-Functional' runs all of them except js.

The reason for doing this is to manage dependencies for tests, and to manage which tool runs the test. The jury is still out on how successful this has been. :-)

There are plenty of places to improve documentation in core and here as well. The main thing is that simpletest is essentially on its way out, so documenting now might be a moving target, but it's also kind of important.

Mile23’s picture

Torenware’s picture

This is a reasonable program. I'll start looking at this.

I'd also agree that running a local test bot is too high a bar; the setup is not only tweaky, it's highly platform dependent. If someone's done a virtual with it, we should point to it, since a good chunk of developers use Macs, and right now, Docker is not very well behaved on Sierra.

Mile23’s picture

$ php ./core/scripts/run-tests.sh --browser --url http://localhost:8888/ --dburl mysql://root:root@localhost:8889/d8 --concurrency 20 --directory ./modules/examples/

Drupal test run
---------------

Tests to be run:
  - Drupal\tour_example\Tests\TourExampleTest
  - Drupal\Tests\examples\Kernel\DescriptionTraitTest
  - Drupal\Tests\examples\Functional\ExamplesTest
  - Drupal\tablesort_example\Tests\TableSortExampleTest
  - Drupal\examples\Tests\ExamplesTest
  - Drupal\simpletest_example\Tests\SimpleTestExampleMockModuleTest
  - Drupal\simpletest_example\Tests\SimpleTestExampleTest
  - Drupal\plugin_type_example\Tests\PluginTypeExampleTest
  - Drupal\Tests\phpunit_example\Unit\AddClassTest
  - Drupal\Tests\phpunit_example\Unit\DisplayManagerTest
  - Drupal\Tests\phpunit_example\Unit\ProtectedPrivatesTest
  - Drupal\phpunit_example\Tests\PHPUnitExampleMenuTest
  - Drupal\Tests\pager_example\Functional\PagerExampleTest
  - Drupal\Tests\page_example\Functional\PageExampleTest
  - Drupal\node_type_example\Tests\NodeTypeExampleTest
  - Drupal\js_example\Tests\JsExampleTest
  - Drupal\file_example\Tests\FileExampleTest
  - Drupal\Tests\field_permission_example\Kernel\FieldNoteItemTest
  - Drupal\field_example\Tests\ColorBackgroundFormatterTest
  - Drupal\field_example\Tests\ColorPickerWidgetTest
  - Drupal\field_example\Tests\FieldExampleMenuTest
  - Drupal\field_example\Tests\Text3WidgetTest
  - Drupal\field_example\Tests\TextWidgetTest
  - Drupal\fapi_example\Tests\FapiExampleWebTest
  - Drupal\email_example\Tests\EmailExampleTest
  - Drupal\dbtng_example\Tests\DbtngExampleTest
  - Drupal\cron_example\Tests\CronExampleTestCase
  - Drupal\content_entity_example\Tests\ContentEntityExampleTest
  - Drupal\config_entity_example\Tests\ConfigEntityExampleTest
  - Drupal\cache_example\Tests\CacheExampleTestCase
  - Drupal\Tests\block_example\Functional\BlockExampleMenuTest
  - Drupal\Tests\block_example\Functional\BlockExampleTest

Test run started:
  Thursday, December 8, 2016 - 03:59
[....]

The --directory argument was added so the testbot could test contrib. :-)

eojthebrave’s picture

This change record looks like it contains some potentially useful information https://www.drupal.org/node/2469723

Mile23’s picture

Status: Active » Needs review
FileSize
3.92 KB

Added a step-by-step for how to run tests in Drupal.

Also changed some phrasing general editing in TESTING.md and STANDARDS.md.

Mile23’s picture

Oh, just realized I forgot to add info about which version of core to track.

eojthebrave’s picture

Should this also include information about running tests via the UI? Not that I would ever really wish that upon someone. :P

Otherwise, this looks like a nice addition. And the final example worked well for me to copy/paste and change a couple of values relative to my installation. Something that took me a while to figure out before. So +1.

Mile23’s picture

Added info about which core branch to use, and how to use the UI to test.

eojthebrave’s picture

That was quick. Nice.

+++ b/TESTING.md
@@ -15,6 +15,12 @@ the testbot's behavior.
+Examples is always targeted to dev branch of Drupal core for the latest release.

I found this sentence to be a bit confusing. I think maybe adding, "to the dev branch" would help.

Otherwise, this looks good to me and I would be fine with calling it RTBC with that change.

navneet0693’s picture

Let's not leave any stones unturned :)

Mile23’s picture

Status: Needs review » Needs work

The patch in #12 has a ton of out-of-scope changes. Maybe do a rebase?

navneet0693’s picture

@Mile23 I had a close look at patch in #10.It deletes certain file, as per my understand, that's somehow by a mistake :). I will work further on patch in #7 Please correct me if I am wrong :)

navneet0693’s picture

navneet0693’s picture

Status: Needs work » Needs review
Mile23’s picture

Status: Needs review » Needs work

If you look at the patch in #12, you'll see that it changes a lot of files other than the testing instructions. Those changes are out of scope.

If you look at the interdiff in #15, it's some of the changes I made in #10.

I'm not sure what to review here, because you seem to have started with #7 and then applied my changes from #10. Did you make any changes in #15?

navneet0693’s picture

Status: Needs work » Needs review

@Mile23 This one is to let everyone as we have already cleared the confusion on this on IRC. So, yes I should have been more clear in comments. Patch in #10 removes certain files, so I started from patch in #7 and applied changes of #10 and included recommendation by eojthebrave in #11. So, actually nothing is changed in #15, it is just I removed the deleted files from patch.

I will change status once again to needs review :)

  • Mile23 committed 34e595e on 8.x-1.x authored by navneet0693
    Issue #2833290 by navneet0693, Mile23, eojthebrave, Torenware: TESTING....
Mile23’s picture

Status: Needs review » Fixed

Sorry about the mix-up. I should be more careful with my patches.

Fixed some 80-char wrap issues in TESTING.md on commit.

Fixed, committed, pushed.

Thanks, folks.

As always: Please file another documentation issue if there's a documentation issue. :-)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.