
Co-authored-by: Marco Borgeaud <89914223+marco-antognini-sonarsource@users.noreply.github.com>
66 lines
2.0 KiB
Plaintext
66 lines
2.0 KiB
Plaintext
== Why is this an issue?
|
|
|
|
For better organization and clarity in test suites, test classes should end with ``++*Test.php++``.
|
|
This naming convention helps to easily identify and distinguish test classes from other classes in the codebase.
|
|
It allows for automated test runners or frameworks to locate and execute the tests systematically.
|
|
|
|
The PHPUnit command-line test runner will look for ``++*Test.php++`` files.
|
|
In that case, test files without this pattern are ignored and not executed without warning.
|
|
|
|
=== What is the potential impact?
|
|
|
|
When tests are ignored or skipped, there can be several negative impacts on the development process and code quality.
|
|
|
|
Firstly, ignoring tests can lead to undetected bugs and vulnerabilities, as the skipped tests are not being executed and their associated functionality is not being thoroughly tested.
|
|
This increases the risk of releasing software with undiscovered issues.
|
|
|
|
Furthermore, skipped tests can result in a false sense of confidence, as developers might assume that the code is functioning correctly without proper validation.
|
|
|
|
This can lead to regression issues or unexpected behavior in the future when changes are made to the codebase.
|
|
|
|
== How to fix it
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,php,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
class TestClassX extends PHPUnit\Framework\TestCase { // Noncompliant
|
|
|
|
public void testDoTheThing() {
|
|
//...
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,php,diff-id=1,diff-type=compliant]
|
|
----
|
|
class ClassXTest extends PHPUnit\Framework\TestCase {
|
|
|
|
public void testDoTheThing() {
|
|
//...
|
|
----
|
|
|
|
== Resources
|
|
=== Documentation
|
|
|
|
* https://phpunit.de/documentation.html[PHPUnit documentation]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|