https://github.com/tommylemon/unitauto-cpp
UnitAuto - ☀️ 最先进、最省事、ROI 最高的单元测试,机器学习 零代码、全方位、自动化 测试 方法/函数,用户包含腾讯、快手、某 500 强巨头等。本项目为 C++ 版,支持 C++ 17 以上 ☀️ The most advanced unit testing way powered by machine learning. Coding-free, comprehensive and automatic testing for methods/functions. Used by Tencent, Kwai, a Fortune 500 company, etc. This repo is the C++ version, compat C++ 17+.
https://github.com/tommylemon/unitauto-cpp
apiauto apijson cpp cpp-library cpp17 unit-test unit-testing unit-testing-library unitauto unitest unittesting
Last synced: 2 months ago
JSON representation
UnitAuto - ☀️ 最先进、最省事、ROI 最高的单元测试,机器学习 零代码、全方位、自动化 测试 方法/函数,用户包含腾讯、快手、某 500 强巨头等。本项目为 C++ 版,支持 C++ 17 以上 ☀️ The most advanced unit testing way powered by machine learning. Coding-free, comprehensive and automatic testing for methods/functions. Used by Tencent, Kwai, a Fortune 500 company, etc. This repo is the C++ version, compat C++ 17+.
- Host: GitHub
- URL: https://github.com/tommylemon/unitauto-cpp
- Owner: TommyLemon
- Created: 2024-07-31T16:54:43.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-11-17T17:02:25.000Z (8 months ago)
- Last Synced: 2025-04-03T10:37:20.977Z (3 months ago)
- Topics: apiauto, apijson, cpp, cpp-library, cpp17, unit-test, unit-testing, unit-testing-library, unitauto, unitest, unittesting
- Language: C++
- Homepage: https://github.com/TommyLemon/UnitAuto
- Size: 292 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# unitauto-cpp
![]()
UnitAuto C++ 库,可通过 GitHub 仓库等远程依赖。
UnitAuto C++ Library for remote dependencies with GitHub repo, etc.同步纯函数:
Sync pure function:
https://github.com/TommyLemon/unitauto-cpp/blob/main/unitauto/test/test_util.hpp#L25-L27struct 成员函数:
strcut member function:
https://github.com/TommyLemon/unitauto-cpp/blob/main/main.cpp#L29-L31class 成员函数:
class member function:
https://github.com/TommyLemon/unitauto-cpp/blob/main/main.cpp#L103-L106
代码覆盖率统计:
Code coverage:
https://cloud.tencent.com/developer/news/1309383
#### 1. 复制粘贴 method_util.hpp & nlohmann/json.hpp 到你的项目
#### 1. Copy & Paste method_util.hpp & nlohmann/json.hpp to your project
https://github.com/TommyLemon/unitauto-cpp/blob/main/unitauto/method_util.hpp如果这个文件已经在你的项目中,只需要在 method_util.hpp 修正 #include "[nlohmann/json.hpp](https://github.com/nlohmann/json)" 为正确的路径
If this file already exists in your project, you need to correct #include "[nlohmann/json.hpp](https://github.com/nlohmann/json)" in method_util.hpp instead
https://github.com/TommyLemon/unitauto-cpp/blob/main/unitauto/nlohmann/json.hpp
#### 2. 注册类型(class/strcut)和函数
#### 2. Register type(class/strcut) and function
由于 C++ 的语言限制,目前做不到像 Java, Kotlin 版几乎绝对零代码,还需要注册 func 和 struct/class 的实例。
Due to the limitation of C++, it's not almost absolutely coding free like Java and Kotlin,
and you need to write few code to register the funcs and structs to be tested.
https://github.com/TommyLemon/unitauto-cpp/blob/main/main.cpp#L226-L260class: UNITAUTO_ADD_CLASS, eg: Moment
```c++
class Moment {
public:
long id;
long userId;
std::string content;UNITAUTO_ADD_CLASS(Moment, id, userId, content)
};
```struct: UNITAUTO_ADD_STRUCT, eg: User
```c++
struct User {
int id;
std::string name;
std::time_t date;UNITAUTO_ADD_STRUCT(User, id, name, date)
};
```static function: UNITAUTO_ADD_FUNC, method(member function): UNITAUTO_ADD_METHOD
```c++
// 注册普通函数,多个可以一起合并注册,超过 64 个可以分拆成多次调用
// Multiple functions(<= 64) can be register on one call
UNITAUTO_ADD_FUNC(add, divide, newMoment, unitauto::test::divide);// 注册类型(class/struct)及方法(成员函数)
// Register type(class/struct) and method(member function)
UNITAUTO_ADD_METHOD(Moment, &Moment::getId, &Moment::setId, &Moment::getUserId, &Moment::setUserId, &Moment::getContent, &Moment::setContent);
UNITAUTO_ADD_METHOD(User, &User::getId, &User::setId, &User::getName, &User::setName, &User::getDate, &User::setDate);
UNITAUTO_ADD_METHOD(unitauto::test::TestUtil, &unitauto::test::TestUtil::divide);
```#### 3. 启动单元测试服务
#### 3. Start unit testing server
https://github.com/TommyLemon/unitauto-cpp/blob/main/main.cpp#L269-L271
```c++
int main() {
unitauto::start(8084);
}
```
#### 4. 参考主项目文档来测试
#### 4. Test by following the main repohttps://github.com/TommyLemon/UnitAuto
### 5. 关于作者
### 5. Author
[https://github.com/TommyLemon](https://github.com/TommyLemon)
如果有什么问题或建议可以 [去 APIAuto 提 issue](https://github.com/TommyLemon/APIAuto/issues),交流技术,分享经验。
如果你解决了某些 bug,或者新增了一些功能,欢迎 [提 PR 贡献代码](https://github.com/Tencent/APIJSON/blob/master/CONTRIBUTING.md),感激不尽。
If you have any questions or suggestions, you can [create an issue](https://github.com/TommyLemon/APIAuto/issues).
If you can added a feature or fixed a bug, please [create a pull request](https://github.com/TommyLemon/unitauto-cpp/pulls), thank you~### 6. 其它项目
### 6. Link
创作不易、坚持更难,右上角点 ⭐ Star 支持下吧,谢谢 ^\_^
Please ⭐ Star the repos that you like ^\_^[UnitAuto](https://github.com/TommyLemon/UnitAuto) 机器学习零代码单元测试平台,零代码、全方位、自动化 测试 方法/函数 的正确性、可用性和性能
[unitauto-go](https://github.com/TommyLemon/unitauto-go) UnitAuto Go 库,可通过 git 仓库等远程依赖
[unitauto-py](https://github.com/TommyLemon/unitauto-py) UnitAuto Python 库,可通过 pip 仓库等远程依赖
[APIJSON](https://github.com/Tencent/APIJSON) 🚀 腾讯零代码、全功能、强安全 ORM 库 🏆 后端接口和文档零代码,前端(客户端) 定制返回 JSON 的数据和结构
[APIAuto](https://github.com/TommyLemon/APIAuto) 敏捷开发最强大易用的 HTTP 接口工具,机器学习零代码测试、生成代码与静态检查、生成文档与光标悬浮注释,集 文档、测试、Mock、调试、管理 于一体的一站式体验
[SQLAuto](https://github.com/TommyLemon/SQLAuto) 智能零代码自动化测试 SQL 语句执行结果的数据库工具,任意增删改查、任意 SQL 模板变量、一键批量生成参数组合、快速构造大量测试数据
[UIGO](https://github.com/TommyLemon/UIGO) 📱 零代码快准稳 UI 智能录制回放平台 🚀 自动兼容任意宽高比分辨率屏幕,自动精准等待网络请求,录制回放快、准、稳!