Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use upper camel case to unify the case name of unit testing cases #3402

Closed
wants to merge 41 commits into from

Conversation

oldme-git
Copy link
Member

@oldme-git oldme-git commented Mar 19, 2024

Dear reviewer:
统一单元测试的函数命名为大写驼峰,向 golang 标准库对齐
加入 ci 检测,不符合要求的抛出 fail,请详细 review .github/workflows/before_script.sh

库里有些单测不是很严谨,同一个包里甚至有 Test_Abc_Def, TestAbcDefTest_abc_def

@oldme-git oldme-git changed the title use Camel case to unify the unit test use upper camel case to unify the unit test Mar 20, 2024
@oldme-git oldme-git added the wip label Mar 20, 2024
@oldme-git oldme-git removed the wip label Mar 21, 2024
@oldme-git oldme-git requested review from gqcn and hailaz March 21, 2024 08:42
@gqcn
Copy link
Member

gqcn commented Mar 21, 2024

@oldme-git 我看改动的文件比较多,都是把下划线改为了大驼峰,但在单测命名这块本身没有规范,这么大量的修改看不出来能给项目带来什么收益。

@gqcn gqcn added the discuss We need discuss to make decision. label Mar 21, 2024
@gqcn gqcn changed the title use upper camel case to unify the unit test fix: use upper camel case to unify the unit test Mar 21, 2024
@gqcn gqcn changed the title fix: use upper camel case to unify the unit test fix: use upper camel case to unify the case name of unit testing cases Mar 21, 2024
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@oldme-git I see that there are many files that have been changed, and the underscores have been changed to hump. However, there is no standard in the naming of single tests. It is hard to see what benefits such a large number of changes can bring to the project.

@oldme-git
Copy link
Member Author

@oldme-git 我看改动的文件比较多,都是把下划线改为了大驼峰,但在单测命名这块本身没有规范,这么大量的修改看不出来能给项目带来什么收益。

单测命名这块的规范官方给的示例都是 TestXxx,第三方规范也都是 TestXxx,哪怕不批量改成TestXxx,也要统一一种风格比较好吧,你看呢

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@oldme-git I see that there are many files that have been changed, and the underscores have been changed to hump. However, there is no standard in naming single tests. It is hard to see what benefits such a large number of changes can bring to the project.

The official examples of single test naming specifications are all TestXxx, and the third-party specifications are also TestXxx. Even if you don’t change them to TestXxx in batches, it’s better to unify one style. You see?

@oldme-git
Copy link
Member Author

oldme-git commented Mar 27, 2024

@gqcn 我详细看了一下 go 标准库,Example 确实会使用下划线,但是单测 Test 没有使用下划线的案例,另外,其他的开源项目,如 opentelemetry-go, gin,都是使用的 TestXxx,当前 gf 两种方式混用,项目大了还是注意一下规范比较好,对齐开源社区的规范也不会带来什么风险

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@gqcn I looked at the go standard library in detail. Example does use underscores, but there is no case of using underscores in single test Test. In addition, other open source projects, such as opentelemetry-go, gin, all use underscores. TestXxx, currently the two methods of gf are mixed. If the project is large, it is better to pay attention to the specifications. Aligning with other open source projects will not bring any significant risks.

@oldme-git
Copy link
Member Author

@gqcn 另外,虽然没有正式的 go 官方标准,但是在开发文档中还是提及了 Test 的命名标准。参见: https://pkg.go.dev/testing#section-documentation

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@gqcn In addition, although there is no formal go official standard, the naming standard of Test is still mentioned in the development documentation. See: https://pkg.go.dev/testing#section-documentation

@gqcn
Copy link
Member

gqcn commented Sep 13, 2024

Close due to in activity for long time.

@gqcn gqcn closed this Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss We need discuss to make decision.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants