Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

lolli42
Copy link
Member

@lolli42 lolli42 commented Nov 30, 2024

phpunit has a best practice that tests should usually have at least one assertion to be sure they actually do something. All assertions thus raise a counter that is checked after test execution. If zero, phpunit marks the test risky with "test has no assertion".

There are two ways to suppress this:

  • Setting beStrictAboutTestsThatDoNotTestAnything="false" via phpunit config
  • Adding #[DoesNotPerformAssertions] attribute to single tests to actively mark tests that do not assert something as legit

Our abstract UnitTestCase spoils this by always doing assertions in tearDown(). The patch turns these
assertions into check+fail() code instead. Unit tests that don't have assertions for whatever reason are now properly marked as risky as intended by phpunit.

Releases: main

phpunit has a best practice that tests should usually
have at least one assertion to be sure they actually
do something. All assertions thus raise a counter that
is checked after test execution. If zero, phpunit marks
the test risky with "test has no assertion".

There are two ways to suppress this:
* Setting beStrictAboutTestsThatDoNotTestAnything="false"
  via phpunit config
* Adding #[DoesNotPerformAssertions] attribute to single
  tests to actively mark tests that do not assert something
  as legit

Our abstract UnitTestCase spoils this by always doing
assertions in tearDown(). The patch turns these
assertions into check+fail() code instead. Unit tests that
don't have assertions for whatever reason are now properly
marked as risky as intended by phpunit.

Releases: main
@lolli42 lolli42 merged commit 4d4fc36 into main Nov 30, 2024
6 checks passed
@lolli42 lolli42 deleted the lolli-1 branch November 30, 2024 16:00
reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this pull request Nov 30, 2024
New TF does not raise assertions in tearDown() anymore [1]
which makes phpunit detect more unit tests that don't
assert something. Some affected tests are legit and receive
the #[DoesNotPerformAssertions] attribute. Some others
were actually broken and are fixed to for instance now
expect calls on mocks. Further minor cleanups along the
way.

> composer req --dev typo3/testing-framework:^9.1.0

[1] TYPO3/testing-framework#660

Resolves: #105730
Releases: main, 13.4
Change-Id: I75289b8242749cb596214566254e7a3da1f7e551
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/87293
Tested-by: core-ci <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
Reviewed-by: Anja Leichsenring <[email protected]>
Reviewed-by: Christian Kuhn <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
Tested-by: Anja Leichsenring <[email protected]>
reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this pull request Nov 30, 2024
New TF does not raise assertions in tearDown() anymore [1]
which makes phpunit detect more unit tests that don't
assert something. Some affected tests are legit and receive
the #[DoesNotPerformAssertions] attribute. Some others
were actually broken and are fixed to for instance now
expect calls on mocks. Further minor cleanups along the
way.

> composer u typo3/testing-framework

[1] TYPO3/testing-framework#660

Resolves: #105730
Releases: main, 13.4
Change-Id: I75289b8242749cb596214566254e7a3da1f7e551
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/87289
Reviewed-by: Stefan Bürk <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Christian Kuhn <[email protected]>
Reviewed-by: Anja Leichsenring <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
Tested-by: Anja Leichsenring <[email protected]>
Tested-by: core-ci <[email protected]>
TYPO3IncTeam pushed a commit to TYPO3-CMS/backend that referenced this pull request Nov 30, 2024
New TF does not raise assertions in tearDown() anymore [1]
which makes phpunit detect more unit tests that don't
assert something. Some affected tests are legit and receive
the #[DoesNotPerformAssertions] attribute. Some others
were actually broken and are fixed to for instance now
expect calls on mocks. Further minor cleanups along the
way.

> composer req --dev typo3/testing-framework:^9.1.0

[1] TYPO3/testing-framework#660

Resolves: #105730
Releases: main, 13.4
Change-Id: I75289b8242749cb596214566254e7a3da1f7e551
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/87293
Tested-by: core-ci <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
Reviewed-by: Anja Leichsenring <[email protected]>
Reviewed-by: Christian Kuhn <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
Tested-by: Anja Leichsenring <[email protected]>
TYPO3IncTeam pushed a commit to TYPO3-CMS/core that referenced this pull request Nov 30, 2024
New TF does not raise assertions in tearDown() anymore [1]
which makes phpunit detect more unit tests that don't
assert something. Some affected tests are legit and receive
the #[DoesNotPerformAssertions] attribute. Some others
were actually broken and are fixed to for instance now
expect calls on mocks. Further minor cleanups along the
way.

> composer req --dev typo3/testing-framework:^9.1.0

[1] TYPO3/testing-framework#660

Resolves: #105730
Releases: main, 13.4
Change-Id: I75289b8242749cb596214566254e7a3da1f7e551
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/87293
Tested-by: core-ci <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
Reviewed-by: Anja Leichsenring <[email protected]>
Reviewed-by: Christian Kuhn <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
Tested-by: Anja Leichsenring <[email protected]>
TYPO3IncTeam pushed a commit to TYPO3-CMS/extbase that referenced this pull request Nov 30, 2024
New TF does not raise assertions in tearDown() anymore [1]
which makes phpunit detect more unit tests that don't
assert something. Some affected tests are legit and receive
the #[DoesNotPerformAssertions] attribute. Some others
were actually broken and are fixed to for instance now
expect calls on mocks. Further minor cleanups along the
way.

> composer req --dev typo3/testing-framework:^9.1.0

[1] TYPO3/testing-framework#660

Resolves: #105730
Releases: main, 13.4
Change-Id: I75289b8242749cb596214566254e7a3da1f7e551
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/87293
Tested-by: core-ci <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
Reviewed-by: Anja Leichsenring <[email protected]>
Reviewed-by: Christian Kuhn <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
Tested-by: Anja Leichsenring <[email protected]>
TYPO3IncTeam pushed a commit to TYPO3-CMS/install that referenced this pull request Nov 30, 2024
New TF does not raise assertions in tearDown() anymore [1]
which makes phpunit detect more unit tests that don't
assert something. Some affected tests are legit and receive
the #[DoesNotPerformAssertions] attribute. Some others
were actually broken and are fixed to for instance now
expect calls on mocks. Further minor cleanups along the
way.

> composer req --dev typo3/testing-framework:^9.1.0

[1] TYPO3/testing-framework#660

Resolves: #105730
Releases: main, 13.4
Change-Id: I75289b8242749cb596214566254e7a3da1f7e551
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/87293
Tested-by: core-ci <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
Reviewed-by: Anja Leichsenring <[email protected]>
Reviewed-by: Christian Kuhn <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
Tested-by: Anja Leichsenring <[email protected]>
TYPO3IncTeam pushed a commit to TYPO3-CMS/backend that referenced this pull request Nov 30, 2024
New TF does not raise assertions in tearDown() anymore [1]
which makes phpunit detect more unit tests that don't
assert something. Some affected tests are legit and receive
the #[DoesNotPerformAssertions] attribute. Some others
were actually broken and are fixed to for instance now
expect calls on mocks. Further minor cleanups along the
way.

> composer u typo3/testing-framework

[1] TYPO3/testing-framework#660

Resolves: #105730
Releases: main, 13.4
Change-Id: I75289b8242749cb596214566254e7a3da1f7e551
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/87289
Reviewed-by: Stefan Bürk <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Christian Kuhn <[email protected]>
Reviewed-by: Anja Leichsenring <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
Tested-by: Anja Leichsenring <[email protected]>
Tested-by: core-ci <[email protected]>
TYPO3IncTeam pushed a commit to TYPO3-CMS/core that referenced this pull request Nov 30, 2024
New TF does not raise assertions in tearDown() anymore [1]
which makes phpunit detect more unit tests that don't
assert something. Some affected tests are legit and receive
the #[DoesNotPerformAssertions] attribute. Some others
were actually broken and are fixed to for instance now
expect calls on mocks. Further minor cleanups along the
way.

> composer u typo3/testing-framework

[1] TYPO3/testing-framework#660

Resolves: #105730
Releases: main, 13.4
Change-Id: I75289b8242749cb596214566254e7a3da1f7e551
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/87289
Reviewed-by: Stefan Bürk <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Christian Kuhn <[email protected]>
Reviewed-by: Anja Leichsenring <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
Tested-by: Anja Leichsenring <[email protected]>
Tested-by: core-ci <[email protected]>
TYPO3IncTeam pushed a commit to TYPO3-CMS/extbase that referenced this pull request Nov 30, 2024
New TF does not raise assertions in tearDown() anymore [1]
which makes phpunit detect more unit tests that don't
assert something. Some affected tests are legit and receive
the #[DoesNotPerformAssertions] attribute. Some others
were actually broken and are fixed to for instance now
expect calls on mocks. Further minor cleanups along the
way.

> composer u typo3/testing-framework

[1] TYPO3/testing-framework#660

Resolves: #105730
Releases: main, 13.4
Change-Id: I75289b8242749cb596214566254e7a3da1f7e551
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/87289
Reviewed-by: Stefan Bürk <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Christian Kuhn <[email protected]>
Reviewed-by: Anja Leichsenring <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
Tested-by: Anja Leichsenring <[email protected]>
Tested-by: core-ci <[email protected]>
TYPO3IncTeam pushed a commit to TYPO3-CMS/install that referenced this pull request Nov 30, 2024
New TF does not raise assertions in tearDown() anymore [1]
which makes phpunit detect more unit tests that don't
assert something. Some affected tests are legit and receive
the #[DoesNotPerformAssertions] attribute. Some others
were actually broken and are fixed to for instance now
expect calls on mocks. Further minor cleanups along the
way.

> composer u typo3/testing-framework

[1] TYPO3/testing-framework#660

Resolves: #105730
Releases: main, 13.4
Change-Id: I75289b8242749cb596214566254e7a3da1f7e551
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/87289
Reviewed-by: Stefan Bürk <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Christian Kuhn <[email protected]>
Reviewed-by: Anja Leichsenring <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
Tested-by: Anja Leichsenring <[email protected]>
Tested-by: core-ci <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants