The scripts/run-tests.sh script has matured a lot during D8, and become the preferred way to run tests (docs). It's main advantage is that there can be no leakage between the parent Drupal site and child Drupal site (because there is no child site when --sqlite is used). This vastly simplifies debugging test failures, and vastly simplifies the test runner itself. However, many folks still appreciate having a UI for choosing tests to run.
This issue proposes to change what happens when the simpletest form is submitted. Instead of actually running the tests, we print out a bash command which calls run-tests.sh with the parameters for chosen by the user in the GUI. More importantly, we can finally rip out all of the code in Drupal which deals with isolation/leakage. We are one step closer to using phpunit as our test runner.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 2312191-14.patch | 4.62 KB | dawehner |
| #5 | simpletestUI.png | 78.2 KB | tim.plunkett |
| #5 | qadoresults.png | 52.74 KB | tim.plunkett |
Comments
Comment #1
dawehnerI really like the idea! Do you think it would make sense to also show the phpunit test command in case you run one of those?
Comment #2
alexpott@dawehner yes if only phpunit tests are selected.
Comment #3
tim.plunkettComment #4
chx commentedwhat i think of this is irrelevant but most definitely get YesCT and webchick approval before doing this.
Comment #5
tim.plunkettUntil I can reliably see the HTML output of pages via the command line, I don't think this will work.
For example, here's what I got via the CLI:
Here's what I got from qa.drupal.org:

And here's what I got from the simpletest UI results:

Guess which one of these helped me find the bug fastest?
Comment #6
dawehner@tim.plunkett
Doesn't --verbose gives you the link when things failed? If not we should certainly add it independent from this issue.
Comment #7
tim.plunkettNope.
Comment #8
alexpottYep we need to be able to use run-tests.sh and end up with a browser window open with the test results and the ability to see any pages visited by the simpletest browser. I think #2253999-3: Provide a way to keep test results and verbose messages as artifacts is the issue to do that. So postponing this on that issue.
Comment #9
sunIn general, I fully agree with the premise of this issue. Especially the parent/child site environment leakage is a fundamental problem of our current testing framework.
That said, I'd like to throw an alternative option into the discussion, which still achieves the same, but retains the UI as-is:
---
Change the (front-end) batch.js to request a custom and minimal test front-controller PHP file, which does NOT boot Drupal, executes a test, and returns test results in a response in the format expected by Batch API.
That will execute the test in a clean and cleanly isolated environment, identically to CLI, merely invoked by a different SAPI.
---
The idea was born when I worked on a cleanup of
run-tests.shsome months ago, with the goal of removing all Drupal dependencies from the script. Truth is, even therun-tests.shCLI script environment leaks, because it boots Drupal prior to executing a test. The prototype successfully worked, but wasn't complete, and it (obviously) revealed that many tests are currently "relying" on leaked environment aspects. Need to grep my sources to find that code.Of course, the web-based front-controller script would not be
run-tests.sh, because that's explicitly designed for CLI. But the task is the same: Bootstrap the most minimal environment possible to execute a test.This most minimal environment is expressed/resembled by
/core/tests/bootstrap.phpalready, which thus presents the benchmark: (1) ClassLoader, (2) Register namespaces, (3) Minimally required constants + PHP INI settings, (4) Done (Run test).Existing Web UIs for PHPUnit are using the identical approach to run tests from a browser. Obviously, as a standalone application, their unique benefit is that they cannot run into the trap of unintentionally priming the environment with application-specific state/aspects, because they're not aware of your custom code in the first place.
However, it should be easily possible to mimic that behavior in a custom UI. In fact, that's relatively simple and not the challenge. The challenge is to fix our existing tests to no longer rely on the environment primed by the test runner.
If we were to pursue this approach, then the necessary roadmap would roughly be:
WebTestBaseto no longer assume a parent site.The test front-controller script simply outputs the test results into the response. We can choose from any serialization format natively supported by PHPUnit (JSON, XML/JUnit, TAP) and re-use its code to generate test result responses for legacy Simpletest tests (until its gone).
The UI simply consumes and processes the response data, purely in the front-end. When running tests through the UI, test results will not be written to any file nor stored anywhere — The test runner/dispatcher/logger is the browser (page) only.
Consequently, the test results page of the UI would be dynamically composed via JS; de facto a micro app in the front-end. Quite possibly, it would even make sense to remove Batch API altogether from the equation, in favor of asynchronous requests to execute multiple tests and/or test suites in parallel. We have plenty of JS/front-end talent that can be leveraged.
I'm fairly confident that this presents a viable alternative solution that still resolves the problems, while retaining a nice UX for newcomers/developers who are intimidated by CLI operations or those who just simply prefer to look at rich HTML output. Thoughts?
Comment #10
moshe weitzman commentedI'd be OK with this. It sounds like more work, but if someone wants to pursue it that's great. I'd love if this HTML+js test runner were developed in its own repo thats not strictly part of Drupal. Drupal would just embed it.
Comment #11
sunIndeed, good point. In essence, it's a new
phpunit_ui.modulethat strictly focuses on providing a UI for executing PHPUnit. It may happen to have a temporary BC layer for legacy Simpletest tests, but that should be an afterthought.However, I'm not sure whether it's possible to achieve this outside of core — unless we'd independently remove the current Simpletest UI(!) upfront + adjust
run-tests.sh+WebTestBaseaccordingly.Comment #12
dawehnerWe now have
--browser and --verbosewhich gives you pretty much all you need already. The result page certainly has all the information you'll ever need.Comment #13
wim leersOMG PLEASE YES
Comment #14
dawehnerHere is a start.
Comment #15
mile23Good idea as a shortcut around the complexity of maintaining the UI testing page.
Good idea in that there are (at least) two testing systems people use regularly, and there should only be one.
Bad idea in that run-tests.sh is really cumbersome, and this issue locks us into its arguments and options, which really need some improvement.
In a better universe, we'd refactor both run-tests.sh and simpletest module to share test-running infrastructure.
Comment #16
mile23In the money-where-my-mouth-is department: #2624926: Refactor run-tests.sh for Console component.
Comment #20
mile23Comment #24
andypostComment #33
mile23Moving to Simpletest contrib issue space.
Comment #34
mondrake