- Issue created by @mxr576
- Merge request !12796Fix test setup class detection to enable use of PHPUnit traits โ (Open) created by mxr576
- ๐ฆ๐บAustralia mstrelan
FWIW I came across similar issues in this commit, but ended up not using it. Might be worth a look. I feel like it might be a bit risky extending the phpunit Assert class.
- ๐ญ๐บHungary mxr576 Hungary
might be a bit risky extending the phpunit Assert class.
Well, TestCase has a required constructor parameter, which conflicts with the way how these test scripts are initiated.
- ๐บ๐ธUnited States smustgrave
Is there currently a nightwatch test that needs this feature?
- ๐ญ๐บHungary mxr576 Hungary
This is a classic โchicken and eggโ situation until this problem is resolved.
Relying on the UI for arrange/setup tasks is high inefficient. It tends to make tests much more flaky and unstable, since browser-based operations are prone to random timeouts or failures. If a single step times out, the entire test could fail unnecessarily. For reliable and fast test execution, itโs better to handle โarrangeโ operations at the API or backend level whenever possible.
- ๐ญ๐บHungary mxr576 Hungary
Well, because the
UserCreationTrait
has many hidden dependency onRandomGeneratorTrait
, so actually it should justuse
it and make the dependency explicit.elseif (!isset($values['name'])) { $edit['name'] = $this->randomMachineName(); }
(from
\Drupal\Tests\user\Traits\UserCreationTrait::createUser()
)