Problem/Motivation
There are two potential removals possible in Drupal 9 in the context of simpletest:
- Mark simpletest as deprecated in 8.8/8.9 and remove it in Drupal 9 potentially: https://www.drupal.org/project/drupal/issues/2847678
- Get rid of the simpletest userinterface, see https://www.drupal.org/project/drupal/issues/2750461
Both decisions are sort of orthogonal as in: You could remove the UI without removing simpletest and you could remove simpletest without removing the UI.
Proposed idea
- Move everything UI related into a
simpletest_ui module, or maybe eventesting_ui module, given it is not just about simpletest - Keep the CLI for simpletest in place. The testingt_ui will be just the user interface you can access via HTTP. run-tests.sh will stay as it is.
- Add a dependency onto simpletest in testing_ui
When this is done, we would have an easier time to do either of the two actions above potentially.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
The simpletest module has been spit into the simpletest module and the testing_ui module.
| Comment | File | Size | Author |
|---|---|---|---|
| #70 | 3028663-70.patch | 72.73 KB | lendude |
| #67 | 3028663-67.patch | 73.92 KB | alexpott |
| #67 | 63-67-interdiff.txt | 4.12 KB | alexpott |
| #63 | 3028663-63.patch | 70.44 KB | alexpott |
| #63 | 62-63-interdiff.txt | 761 bytes | alexpott |
Comments
Comment #2
dawehnerComment #3
dawehnerMoving from task to plan.
Comment #4
alexpott+1 - I think we should also consider calling the UI module testing_ui rather than simpletest.
Comment #5
mile23So duplicate of #2866082: [Plan] Roadmap for Simpletest then.
Comment #6
berdirCame here to say this.
Comment #7
dawehnermisread @mile23's comment
Comment #8
dawehner@mile23
You are right as in this is a subset of what the other meta issue is about. This issue doesn't try to refactor anything beside splitting up the module.
Comment #10
dawehnerHere are a couple of fix, many related to the stable theme. I'm not sure what to do about those to be honest. Given we move the theme etc. into the new place should we keep or rename things so existing templates continue to work?
Comment #12
dawehnerSome fixing of the failures.
Comment #14
mile23The fail says:
The 'online documentation' link for simpletest.module goes to the Drupal 7 page.
Like the test fail says, there's no link to online documentation for this module, so we'll have to make some and link to it.
Comment #15
lendudeAdded the link to the simpletest docs for now, just to see if that gets this in the green. We can discuss if this needs its own doc page or that we need to update the simpletest docs to show that this is now two modules.
Interdiff added some stuff I didn't change, just did the docs link.
Comment #17
amateescu commentedWe have patches in here, so it's not only a plan anymore :)
Comment #18
lendudeNeeded a reroll, so here we go, no other changes added.
One thing that needs to be addressed still is the splitting of the /tests/ into stuff dealing with the UI and stuff dealing with the test runner/WebTestBase.
Comment #19
dawehnerHere are some moved tests. I think we should ideally split up some of the other tests like
SimpleTestTest, given they contain both simpletest and UI bits.Comment #22
gábor hojtsyI think its clear that the simpletest API module would be useful from drush/drupal console. If for some reason we want to keep it. Please explain in the IS what would testing_ui in itself allow you to do without simpletest API, so the reasoning behind this issue is outlined.
Comment #23
dawehner@Gábor Hojtsy
Does this update help you?
Comment #24
gábor hojtsy@dawehner: no, if we are to write the change notice for removing the API module but not the UI module, we would be writing: "We removed the simpletest API module however kept the test runner user interface because it is still useful for [FILL THIS IN]." I am looking for [FILL THIS IN] since that explains why breaking them up is useful in the first place.
Comment #25
dawehnerI adopted the issue summary to link to the "mark webtestcase deprecated issue". If we mark it deprecated now, and drop it for D9, what happens with the existing UI.
This module tries to make it easier to make the two decisions independent from each other.
Comment #26
joachim commented> Please explain in the IS what would testing_ui in itself allow you to do without simpletest API, so the reasoning behind this issue is outlined.
1. Running stuff on the command line is complicated and scary for a lot of users. A browser-based UI is nice and simple. We want new contributors to get into the habit of running tests.
2. Functional tests where you want to check the HMTL output during a test are a pain on the CLI, because you're switching between the terminal and the browser. Back in the old days of Drupal 7 it was much nicer to see both browser test output and test log in the browser.
Comment #27
mile23Similar but slightly different #2866082: [Plan] Roadmap for Simpletest suggests making the simpletest module only show the UI form and manage in-site test runs, while moving all test-runner-related code into core/tests/. That would require some refactoring, which I assume maintainers are loathe to do because it seems risky. (I assume because no one will actually say...)
This issue splits the code differently, so that we don't do any refactoring of the test-runner code, we only split it up into two modules. That makes some sense if you're not sure which code is needed for which parts of the testing system. But if you're not sure, you could just ask Mile23, who researched it all to file #2866082: [Plan] Roadmap for Simpletest.
The summary is: It's trivial to split out the UI part and the in-site batch runner, so that's a task that we can take on and get the ball rolling. Whether we do it as part of a plan to refactor run-tests.sh to be better or whether we do it in order to kill run-tests.sh is another question entirely, and one that we really should answer before we do much more work.
Comment #28
mile23The browser-based UI is simple but it's wrong. For instance if you select a group, you're likely to not run all the tests you mean to run. #2296615: Accurately support multiple @groups per test class There are many other bugs, too. #2215035: [meta] Simpletest UI cleanups
Splitting out the UI means it's both easier to deprecate and also easier to fix and keep even if we abandon run-tests.sh.
Comment #29
joachim commented> The browser-based UI is simple but it's wrong.
Sure, but what you mean is that it's *currently* wrong, but not inherently wrong.
I was just commenting because @Gábor Hojtsy said he hadn't been given any reasons for keeping the UI.
FWIW I'm totally in favour of the cleanup roadmap @Mile23 has presented elsewhere, I just don't feel competent enough to help that much with it.
Comment #30
dawehnerThe problem is, I don't really get this really. When you are working on any development related task you will need a command line these days. Every frontend project relies on it. With composer, aka. best practises, we rely heavily on the command line, so from my perspective it is less useful. Some points in #2750461: Remove Simpletest UI because we don't want to maintain a graphical test runner seems to be related with the userguide, but I don't fully understand why we couldn't work together to use the phpunit command line tool for that.
In order though to be able to make progress, see the issue summary we could split the two conceptual different pieces up, so decisions can be made independent from each other.
Comment #31
damienmckennaThis task makes sense in the same way that we have Views vs Views UI and Field vs Field UI. Let's move the meta discussion to #2750461: Remove Simpletest UI because we don't want to maintain a graphical test runner.
Comment #32
mile23Again: The meta discussion shouldn't be about the UI because it's relatively easy to fix and also relatively easy to remove. Especially with PHPUnit, maintaining the in-browser runner isn't all that tremendous a technical feat; it only requires a decision about what to do.
The meta discussion should be: Are we transitioning away from run-tests.sh in favor of something else, and what is it? Here is that meta: #3030136: The Fate Of Run-Tests.Sh
When we have that answer, we will be able to determine why we should split simpletest into two modules.
Since it's impossible to search for 'run-tests.sh' on d.o, here's a meta: #2626986: [meta] Improvements to run-tests.sh and it has the tag 'run-tests.sh.'
Comment #33
mile23Reroll of #19 and minor change to (hopefully) fix the test fail.
Comment #35
mile23More test passing.
Comment #36
joachim commentedLooks good. A few minor points:
The permission is being moved to testing_ui module, so shouldn't it stay granted to the test user here?
Nitpick: core is inconsistent on Ui / UI in class names, but UI comes out narrowly ahead.
Case problem.
Comment #37
mile23Re: #36.1:
SimpleTestBrowserTestonly tests the behavior of the internal browser. The permission might not have been needed before splitting the modules out, but definitely is not needed now. The permission is in the ui module which isn't a requirement of this test. We do have to have a logged in user fortestUserAgentValidation()so we keep the login part.#36.2: Consistent with other class/file names in the same folder.
#36.3: Done.
Comment #38
joachim commentedThanks!
In that case, I'm going to say RTBC.
Comment #39
alexpottLet's land this early in 8.8.x - there's no need to add to the 8.7.x pressure with this issue. The alpha deadline is today.
We need to update CRs hook_update_N's etc...
Big +1 to doing this.
Comment #40
lendudeComment #41
jibranI think we need a change notice as well.
Comment #42
mile23Added CR: https://www.drupal.org/node/3038814
We will need to update the testing documentation here: https://www.drupal.org/docs/8/core/modules/simpletest
Possible follow-up would be to move the batch test runner to testing_ui, since it's the only place that uses it. That would be
simpletest_run_tests()and friends, and would affect #2748967: Trigger E_USER_DEPRECATED for BC support in simpletest_run_tests()Comment #43
lendudeI updated the IS in #40 so removing the tag, CR looks great, all feedback looks addressed.
Comment #44
gábor hojtsyGiven a new module added and modules split, needs release managers.
Comment #45
catchWhat's the simpletest dependency necessary for at this point, could it be optional? Or is that a further follow-up?
Comment #46
lendude@catch it has a dependency for the test_discovery service, which should probably be moved out of simpletest at some point? Quick google didn't turn up an issue specifically for that.
Comment #47
mile23If you're looking for old issues dealing with refactoring the testing system to be more maintainable and that probably need a re-roll because the poster is alone in the wilderness, then just search for "mile23 [testing component here]"
#2863055: Move TestDiscovery out of simpletest module, minimize dependencies
Note that if you look through run-tests.sh and find all the simpletest_* function calls that don't start with simpletest_script_*, those are the only dependencies between run-tests.sh and simpletest module.
Similarly, the new testing_ui module doesn't use any of that for running tests, and uses the batch functions from the simpletest module.
So if we moved the batch functions to testing_ui, and we moved the dependencies from run-tests.sh to somewhere else, we'd have successfully deprecated simpletest module.
If someone will file those issues I'll gladly do them, because, as mentioned, kind of tired of being alone in the wilderness.
Comment #48
larowlanComment #49
mile23Reroll.
Comment #50
mile23Comment #51
mile23Not sure how that happened.
Comment #52
catchfwiw I don't have a strong preference on this issue vs. #2863055: Move TestDiscovery out of simpletest module, minimize dependencies landing first especially given they're both close. Makes sense to me to land this issue in 8.8.x
A new module could probably use product manager review though, although the eventual goal is to go back down to one or zero modules.
Comment #53
mile23#2863055: Move TestDiscovery out of simpletest module, minimize dependencies is tagged for 8.7.x since it's a test-only change, and this one is 8.8.x since it's disruptive. It might be easier to change TestDiscovery first but not a problem either way.
Comment #54
lendudeReroll looks good, back to RTBC.
Comment #55
alexpottRerolled due to a conflict in simplest.module due to deprecation of \Drupal::url().
Fixed:
Also fixed the following coding standards:
Comment #56
bojanz commentedIf this issue is 8.8-only, shouldn't we bump the update function number?
Comment #57
alexpott@bojanz good point - also no need for that to be a hook_update_N()
Comment #58
alexpottLet's add some update test coverage.
Comment #59
lendudeReroll and updated update and test coverage look good, back to RTBC
Comment #60
naveenvalechawe would need the test coverage for this
These needs to be resolved.
Nitpick: This should be TestingUiResultsForm
Nitpick: The form class name should be updated.
Setting it back to N/W for point 2.
Comment #61
alexpottPatch addresses #60.
Re #60.1 - test coverage was added in #58 - it only needs one line :)
All the other points from #60 are addressed by this patch.
So there's a bit more work to do here. I've tested the --browser option on run-tests.sh - the attached patch fixes it
but it looks very unthemed if testing_ui is not installed - I think that's okay(EDIT: I'm wrong - we linked to the uninstalled testing UI's css and js and it looks great - this is what we do in HEAD too if simpletest is not installed).More serious is what to do about
In reality these are all testing UI functions and now simpletest_run_tests() depends on the testing UI library (this was broken in previous patches) - but moving simpletest_run_tests() is against our BC policy. I would argue strongly that no one is calling simpletest_run_tests() and http://grep.xnddx.ru/search?text=simpletest_run_tests&filename= would back me up but it is strictly against how BC policy to make this kind of break. But perhaps because this is testing functionality and not involved in runtime of a site we can make an exception here. In a way this applies to the theme and library changes the patch already is making. Anyhow because of this I've moved them in the attached patch and added the "needs release manager review" tag.
I've also hardened \Drupal\KernelTests\Core\Asset\AttachedAssetsTest::testAlter to not produce false positives as it was in previous patches.
I've also added the "Needs manual testing" tag because whilst there is test coverage of much of the UI it is by no means complete. This patch also fixes #60.4 which if @naveenvalecha had not caught would have resulted in a broken re-submission of failed tests through the UI.
Comment #62
alexpottWhilst reviewing #61 I noticed some more inconsistencies.
Comment #63
alexpottOops missed one thing.
Another thing we need to think about is the config
simpletest.settings.Atm it looks something like this
clear_resultsis used by both run-tests.sh and the Testing UI viasimpletest_clean_environment()httpauthis only supported by deprecated Simpletest tests - ie things that extend\Drupal\simpletest\TestBase- I think this makes the config essentially useless. We should search the issue queue and see if anyone has struggled with this whilst using PHPUnit based functional tests. Perhaps we can deprecated this configuration too.verboseis only used by the UI and really belongs in a testing_ui configuration. I think it is also only supported by deprecated Simpletest tests and therefore probably should be deprecated and therefore not worth moving. Note this setting is often confused with verbose error level logging and the --verbose option in run-tests.shComment #64
catchIs there something stopping us deprecating simpletest_run_tests() and having it call testing_ui_run_tests()?
Comment #65
alexpott@catch dependencies - simpletest is a dependency of testing_ui and not the other way around. We could do that with a moduleExists check I guess because if you were using simpletest then testing_ui will be installed. However that's not how most people use it - they install simpletest for testing and then uninstall it. Or install it as part of some build process. So perhaps we need to install testing_ui in simpletest_hook_modules_installed() when simpletest is installed.
Comment #66
catchhmm what about emptying it except for a trigger_error() and deprecating it, then on the 0.001% chance that's someone's calling it they'll immediately know what happened.
Comment #67
alexpott@catch yep we can do that. I've triggered a deprecation when Testing UI is installed and we have a replacement and error when its not because we can't do much else. Added tests for this.
Comment #68
mile23#65 is part of why #2866082: [Plan] Roadmap for Simpletest emphasizes moving functions out of modules altogether. If we do things like, for instance, #2641632: Refactor simpletest's *_phpunit_*() (and junit) functions etc. to a class, deprecate then we don't create a module-to-module dependency problem. In the case of
simpletest_run_tests()if we must have a batch runner then we should turn it into some classes that live incore/lib/Drupal/Core/Tests. Then simpletest module can depend on it for function-calling BC, and testing_ui can also depend on it to run the tests for the user.Comment #69
alexpott@mile23 but the batch system in Drupal is really part of the FormAPI and running tests from forms is what the UI is for. So I think putting them in the new Testing UI module and not as part of Core makes sense. Another reason this is correct is this is where the asset libraries are added - you do not want to be doing this in Core.
Comment #70
lendudeNeeded a reroll, so here we go.
Also went through this again with the mindset 'If I just delete the testing_ui dir, what breaks?' and the main thing that stood out was this:
run-tests.sh now has a dependency on two modules, is there no way to avoid that? Maybe make it optional? Give a warning when using the browser option and testing_ui is disabled?
Comment #71
mile23OK, check this out.
run-tests.sh says this so it can build the results form for
--browser:That method is static specifically so that run-tests.sh can run it without having to use the whole form builder API. run-tests.sh can just call it and then render it without building a form state, but the UI can also call it and render it inside a form context.
Now, if we look within
TestingUiResultsForm::addResultForm(), it says this:So wherever it is that this method lives, we have a hard dependency on simpletest module, because that's where
TestDiscoverylives.But what if it didn't? What if it lived in
core/lib/Drupal/Core/Test/? If it were there, then it would be autoloadable from all the places that need it, but not create a dependency on the simpletest module.As it turns out, that work has been done, except for a reroll I'll do now: #2863055: Move TestDiscovery out of simpletest module, minimize dependencies
So that's one area where this web of dependencies is now reduced, because we refactored the code to be in a *third* place, instead of the two modules.
Now take this line of reasoning and apply it to all dependency problems we see here, such as #65 and #70. We move those things to a *third* place, namely
core/lib/Drupal/Core/Test/. This way we can shim BC for simpletest module as needed, while also allowing testing_ui to remain dependency-free.Postponing here on #2863055: Move TestDiscovery out of simpletest module, minimize dependencies which has some consensus already.
Later, we can factor out the static method
TestingUiResultsForm::addResultForm()into a helper class incore/lib/Drupal/Core/Test/, which will be used by both the testing_ui form, and also run-tests.sh.Comment #72
mile23Currently, it seems as though the plan is to turn the simpletest module into a contrib module, with work happening in this meta: #3057420: [meta] How to deprecate Simpletest with minimal disruption
This has the effect of moving the test runner parts of the module into core, leaving the testing UI part and the WebTestBase framework as a contrib module.
Comment #74
catchWe ended up moving simpletest to contrib, so marking this one as outdated.
Comment #75
xjm