stretchr / testify

A toolkit with common assertions and mocks that plays nicely with the standard library
MIT License
22.5k stars 1.56k forks source link

Generate better comments for require package #1610

Open Neokil opened 3 weeks ago

Neokil commented 3 weeks ago

Summary

The comments for the require package were just copied over from the assert package when generating the functions. This could lead to confusion because

  1. The code-examples were showing examples using the assert package instead of the require package
  2. The function-documentation was not mentioning that the functions were calling t.FailNow() which is some critical information when using this package.

Changes

  1. Added a "replace" function to the template
  2. require.go.tmpl now replaces the package name accordingly
  3. require.go.tmpl now adds another line to the function-docs explaining the difference to the assert-function

Motivation

When new developers are coming in they most likely did not go through the github-documentation for every package used in the application. But what they do is read the function-docs when they go through code to understand what it is doing. In case of test-cases using both require and assert it gets confusing because the function docs for the require package are referencing the assert package and don't really document the actual function.

dolmen commented 3 weeks ago

I've just merged #1607, so please rebase and run codegen.

hendrywiranto commented 3 weeks ago

this will close https://github.com/stretchr/testify/issues/1609 too

Neokil commented 1 week ago

somehow I cannot add reviewers the to the PR, but maybe @boyan-soubachov, @dolmen, @MovieStoreGuy, @arjunmahishi or @brackendawson can one of you have a look?