You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
generate black-box tests in a _test package (-package_test) (#206) (3325c5e), closes #33. Based on #199 by @IlyasYOY.
The new -package_test flag (Options.PackageTest) generates tests in package <pkg>_test that import the package under test. It implies -exported.
Calls and types from the package under test are qualified, including inside composite types, receivers and generic instantiations. Works with the default and testify templates; custom templates can use the PackageTest and PackageName fields.
Functions whose signatures use unexported types, and methods on unexported types, are skipped and reported (Skipped <func>: <reason>, or the new Options.OnSkip callback). Unexported struct fields are left out of receiver setup.
Bug Fixes
skip benchmark functions when generating tests (#205) (22dadae), closes #93. Functions taking *testing.B no longer produce a test that calls the benchmark.
Behavior changes
Existing <pkg>_test test files are now extended in black-box mode automatically, even without -package_test (#206). Previously gotests added unqualified calls and types to these files, which did not compile. Output for such files changes: calls and types are qualified, only exported functions get tests, and the black-box rules above apply. An existing import of the package, including its alias, is reused.
Adding -package_test tests to an existing internal (package <pkg>) test file is refused with an error, since it would break that file's tests.