Urgent.News

What's breaking now, across thousands of outlets.

Tech

Using non-breakable spaces in test method names

This article discusses the practice of using non-breaking spaces in test method names. The author explains that this approach is valid PHP code that works effectively. Non-breaking spaces, also known as HTML entities, appear as spaces in editors but are treated like any other character by PHP.

In the past, the author's team at Wizaplace used a different naming convention, such as snake_case instead of camelCase, for test methods. This change aimed to provide clearer explanations of what each test does. Although this style was not fully compliant with PSR-2 standards, the team gradually became comfortable with it.

The author shares that the team experimented with using non-breaking spaces in test method names. They found this approach to be even more readable than their previous style. They conducted a small controlled experiment and found it to be a great success over a year later. The tests remained clear and meaningful, making the entire testing process more understandable.

The author highlights that test methods written as sentences contribute to better clarity. They provide examples of pull requests where this naming convention was implemented. While some syntax highlighting tools initially had issues, they were resolved in subsequent pull requests.

Introducing this new naming convention to the team was initially challenging for new colleagues. However, the author emphasizes that once explained, the team quickly adapted to the new style. Both junior and senior developers embraced the change easily.

The author acknowledges that implementing non-breaking spaces in open-source projects could be more difficult, as contributors may not have direct guidance from the team. However, they believe that once the concept is explained, the benefits of using this style in practice are clear. They conclude by stating that, in their experience, employing non-breaking spaces in a closed-source project is straightforward, and they are happy with the results.

Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at mnapoli.fr →

More in Tech

Point the official Sentry SDK at self-hosted ingest (DSN only)

You don’t need a forked Sentry SDK. Keep @sentry/browser or @sentry/node , change only dsn , then prove /health → HTTP 202 → Issues.

  • Clone the public repo and run Docker Compose to set up self-hosted ingest.
  • Install pinned official Sentry SDK (7.120.0) with custom DSN and settings.
  • Verify SDK ingestion by capturing an exception and checking for 202 response.

More from Sunday 20 September →