[policy, no patch] Discuss the standards for data providers phpunit based tests

Created on 24 October 2017, over 7 years ago
Updated 19 June 2024, about 1 year ago

Part of #2057905: [policy, no patch] Discuss the standards for phpunit based tests β†’

Problem/Motivation

We have no standards for how data providers are documented in PHPUnit tests. If we follow the core standards of documenting @return and @param tests will have a lot of boilerplate that does not add much. However, if we mandate that every set of arguments is keyed by a meaningful string then this is super useful.

Proposed resolution

tbd

Remaining tasks

Come up with an enforceable standard

πŸ“Œ Task
Status

Active

Component

Coding Standards

Created by

πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΊAustralia mstrelan

    In PHPUnit 11 we'll need to use the #[DataProvider] attribute. Not sure we need to enforce any particular naming convention if we have this.

  • πŸ‡ΊπŸ‡ΈUnited States xjm

    In πŸ“Œ Rename mis-named data providers discovered in #3421418 Postponed , we also noticed a few data providers that were named testSomethingSomethingProvider(), rather than the more common providerTestSomethingSomething(). It might be worth having an explicit standard about the naming, especially since the pattern of those three methods made it look like they were test methods themselves rather than data providers. (I don't know if PHPUnit actually tries to run them, but it is confusing.) Added to the IS.

  • πŸ‡ΊπŸ‡ΈUnited States xjm
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    Adding the new template

  • πŸ‡ΊπŸ‡ΈUnited States xjm

    As I mentioned on the other issue, I also am not sure if lumping naming with documentation expectations is correct. It should possibly be separate issues.

  • πŸ‡¦πŸ‡ΊAustralia mstrelan

    The issue title "Discuss the standards for data providers in PHPUnit-based tests" to me suggests a holistic approach. Happy for someone else to split it in to multiple tickets, but it makes sense to me to discuss it as a whole in this issue and split off once concrete decisions are made.

  • πŸ‡¬πŸ‡§United Kingdom joachim

    > However, if we mandate that every set of arguments is keyed by a meaningful string then this is super useful.

    That is super useful, but it's code, not documentation. Out of scope for this issue?

    > If we follow the core standards of documenting @return and @param tests will have a lot of boilerplate that does not add much.

    Documenting both the @return of the provider and the @params of the tests is writing the same thing twice, and redundant, but *one* of them should be documented!

Production build 0.71.5 2024