How to Share Test Utility Functions Between Packages?

Susan Sarandon
Release: 2024-11-03 23:40:30
Original
261 people have browsed it

How to Share Test Utility Functions Between Packages?

How to Share Test Utility Functions Between Packages

Q: "How to reuse test code in imported packages?"

A1: It is generally advisable to move utility functions used in testing across multiple packages to a separate "utils" package and import this package in your *_test.go files.

However, if the utility functions rely on private functions in the imported package, a modified approach is necessary.

A2: Save the output of the private function in a support file. Then, load the support file when calling the support package's function that utilizes the private function.

The above is the detailed content of How to Share Test Utility Functions Between Packages?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!