Problem/Motivation
Examples currently doesn't demo how to set up test types other than Simpletest and unit tests.
Proposed resolution
Add an example module called testing_example, which will demo the different types of frameworks available from Drupal 8.
This won't include simpletest.
Find tutorials in https://www.drupal.org/docs/8/phpunit and support them.
Document how to run the various testing tools as part of the content of this module's description, or even on another page.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | interdiff.txt | 10.04 KB | mile23 |
| #15 | 2821403_15.patch | 16.46 KB | mile23 |
| #13 | interdiff.txt | 15.98 KB | mile23 |
| #13 | 2821403_12.patch | 17.23 KB | mile23 |
| #11 | 2821403_11.patch | 17.45 KB | mile23 |
Comments
Comment #2
rfayHere's the patch adding those two and updating the docs displayed on visiting the module page.
Comment #4
rfayAdded @group annotations.
Comment #5
ifreeman commentedThis patch shows an alternate way to create a node via a new test, which I think will be more appealing. Some minor code reformatting is also done.
Comment #6
rfayThanks @noobish - great thinking.
This patch just makes minor changes to what you did, and also ports the actual simpletest test, which I had forgotten about.
Comment #7
mile23#2833290: TESTING.md does not explain how to test the modules
Comment #8
mile23Comment #9
mile23Thanks for this. We really need this expansion, and I'm OK with the changes.
There are so many caveats to add here, such as SIMPLETEST_DB and... Ugh. D8 testing is a bit of a complicated game which is unfortunate. But we should document as much as we can.
Also, you can do the same thing this way:
phpunit -c core/ --printer '[stuff]' --testsuite functional --group phpunit_exampleThere are a bunch of coding standards problems here. Consult
STANDARDS.mdfor how to check them: http://cgit.drupalcode.org/examples/tree/STANDARDS.mdCoding standards errors:
Comment #10
mile23Comment #11
mile23Let's switch it up here.
Let's make an example module called testing_example. This will be clearer to anyone who doesn't understand the distinction between simpletest and phpunit.
We'll leave simpletest_example and phpunit_example for now. We might fold them in later, but probably not.
For now, phpunit_example can demonstrate generic phpunit techniques such as mocking and data providers.
testing_example will show you how to do more Drupal-y stuff involving having a fixture site (or fixture kernel) to manipulate.
simpletest_example will stay mostly the same and probably won't see much maintenance. We can just remove it for D9.
Here's a patch that moves all the additions here to testing_example, with some updates and edits.
Comment #12
mile23Comment #13
mile23Fixed a lot of CS errors.
Renamed tests with Simple in the name to Example. We're trying not to confuse people who are used to simpletest. :-) We could probably just rename them
NodeTestandUserTest.Updated some docblocks and the module's real functional test.
I don't think we need
ExampleKernelUserTest(formerlySimpleKernelUserTest) because it's almost identical to the node test, and it doesn't test anything other than that the test framework is functioning properly.Comment #15
mile23Looking at the last test, it had a testbot failure after all the tests passed. https://www.drupal.org/pift-ci-job/732363
Consolidating the kernel tests into
ExampleFixtureManagementTest, since they demonstrate how to set up fixture content and users.Some tweaks and comment updates to
ExampleFunctionalTest.Comment #16
mile23Adding follow-ups to #2900144: Update content of testing_example and #2821406: Add JavascriptFunctional example test(s) to testing_example
Comment #18
mile23Committed and pushed. Thanks folks!
Anyone wishing to add a feature request, please file a new issue against the Testing Example component. Thanks!