Closed (fixed)
Project:
Drupal core
Version:
8.7.x-dev
Component:
simpletest.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
26 Jun 2018 at 17:05 UTC
Updated:
6 Feb 2019 at 23:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mile23Comment #3
mile23Comment #5
lendudeJust poking around this. The docblock for the test states:
* If a test case does not call parent::setUp(), running
* \Drupal\simpletest\WebTestBase::tearDown() would destroy the main site's
* database tables. Therefore, we ensure that tests which are not set up
* properly are skipped.
Well, that is not true (edit: For BTB at least). I can run a BrowserTestBase with an empty setUp method without problems from the command line and the Simpletest UI.
It also appears to me, that the test is actually doing something with broken tearDown more then broken setup. But I don't get what it's testing completely yet.
Comment #6
lendudeComment #7
lendudeDuplicating this 'as is', is pretty hard, also, we would lose the coverage if (when?) we lose the Simpletest UI.
Would a simple Unit test that makes sure we don't call cleanEnvironment if setUp isn't called do the trick?
Comment #8
jibranI think duplicating the test is a great ideal. Let get this in.
Comment #9
alexpottYep this seems like a good test of the situation. Once we have $this->kernel we have installed the test site properly so testing that we never call this method makes sense.
However the new test is extremely brittle because there is no validation that the
cleanupEnvironment()method exists.I suggest changing the test to be something like:
Without the
$this->assertTrue(method_exists(BrowserTestBase::class, $dangerous_method));you can change$dangerous_methodto something likefoobarand the test will pass. Basically tests without only negative assertions are always a red flag.Comment #10
lendude@alexpott yeah that makes sense, updated. Also changed the group of BrokenSetUpTest to 'WebTestBase' to follow the pattern in #2932909: Convert web tests to browser tests for Simpletest module
Comment #11
jibranNice suggestion @alexpott.
Comment #12
alexpottCommitted and pushed 4da678eb5f to 8.7.x and eb3e150d72 to 8.6.x. Thanks!