Closed neuberkauf closed 7 months ago
This is how Codeception step works. It converts action name to words and appends all arguments. It looks much better when you use a module that was properly designed for Codeception:
I am on page "/about"
I click "button"
I see "some text"
I aggree that Asserts step output is ugly, but there is not much we can do short of rewriting Asserts module and/or Codeception.
assertThat
is the only method that takes constraint as parameter, the output could be improved by modifying Step class to call toString
- https://github.com/Codeception/Codeception/blob/7d754d1891316d8c525fdb8a0ad7811c5cb9f955/src/Codeception/Step.php#L169-L179
Generating step outputs from method names is one of the main Codeception ideas, I don't thing that it can be replaced with something similar to Constraint.
i figured the Assert language is coming from the underlying PHPUnit. No big deal there.
Adjusting to handle Constraint objects would be fantastic. Seems like a simple thing if you'd like me to check out and submit a PR.
$ php codecept run unit tests/unit/Codeception/StepTest.php
Codeception PHP Testing Framework v5.0.12 https://stand-with-ukraine.pp.ua
[Seed] 109444475
Unit Tests (12) ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
✔ StepTest: Multi byte text length is measured correctly(0.74s)
✔ StepTest: Single quoted string as argument(0.00s)
✔ StepTest: See uppercase text(0.00s)
✔ StepTest: Get arguments(0.15s)
✔ StepTest: Array as argument(0.00s)
✔ StepTest: No args(0.00s)
✔ StepTest: Constraint output(0.24s) * new *
✔ StepTest: Formatted output(0.02s)
✔ StepTest: See multi line string in single line(0.00s)
✔ StepTest: Am on url(0.00s)
✔ StepTest: Get html(0.00s)
✔ StepTest: Long arguments(0.02s)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Time: 00:05.290, Memory: 12.00 MB
OK (12 tests, 24 assertions)
(Sorry for posting under two accounts... This one is my work account - i forgot to switch over.)
What are you trying to achieve?
I'm probably overlooking something dumb, but searching around for this hasn't produced much help.
When running tests verbosely (
-vv
,-vvv
), i want each assertion's output to read neatly, using the Constraint's self-describingtoString()
. For example:i expect something like:
I assert that true is true
I assert false is false
What do you get instead?
The first one is especially off-putting. Why is it using the Constraint's FQN?
I assert that true, "PHPUnit\\Framework\\Constraint\\IsTrue"
I assert false false
Codeception PHP Testing Framework v5.0.12 https://stand-with-ukraine.pp.ua
Tests.Unit Tests (1) ------------------------------------------------------- Modules: Asserts
TestCest: Default Signature: Tests\Unit\TestCest:default Test: tests/Unit/TestCest.php:default Scenario -- I assert that true,"PHPUnit\Framework\Constraint\IsTrue" I assert false false PASSED
Time: 00:00.513, Memory: 4.00 MB
OK (1 test, 2 assertions)
Details
Codeception version: 5.0.12
PHP Version: 8.1.x
Operating System: Windows, and WSL (AlmaLinux 9.2)
Installation type: Composer
List of installed packages (
composer show
) This is the minimal functional install i can get to, but it doesn't change when i add back all my typical packages.Composer:
Suite configuration:
actor: UnitTester modules: enabled: