Skip to content

Commit f657ad7

Browse files

File tree

8 files changed

+217
-33
lines changed

8 files changed

+217
-33
lines changed

UnitAuto-Admin/apijson/CodeUtil.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6036,6 +6036,7 @@ var CodeUtil = {
60366036
return valuesIsNotString ? ' ! value必须是String类型!且必须符合 countArray 这种方法名格式!' : (isWarning ? '' : CodeUtil.getComment('被调用方法名', false, ' '));
60376037
case 'constructor':
60386038
return valuesIsNotString ? ' ! value必须是String类型!且必须符合 getInstance 这种方法名格式!' : (isWarning ? '' : CodeUtil.getComment('获取类实例的方法名,一般用于单例模式类', false, ' '));
6039+
case 'args':
60396040
case 'methodArgs':
60406041
case 'classArgs':
60416042
if (value == null || value instanceof Array) {
@@ -6535,6 +6536,7 @@ var CodeUtil = {
65356536
if (CodeUtil.getType4Request(value) == 'string') {
65366537
return isWarning ? '' : '获取类实例的方法名,一般用于单例模式类';
65376538
}
6539+
case 'args':
65386540
case 'methodArgs':
65396541
case 'classArgs':
65406542
if (value == null || value instanceof Array) {

UnitAuto-Admin/index.html

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,11 @@
315315
{
316316
"static": true,
317317
"methodArgs": [
318-
{ // 可省略来自动判断的 type: Boolean,Integer,BigDecimal,String,JSONObject,JSONArray
318+
{ // 可省略来自动判断的 type: Boolean,Integer,BigDecimal,String,JSONObject,JSONArray
319319
"type": "long",
320320
"value": 1
321321
},
322-
{ // 这个对象还可以简化为 "int:2" 这种字符串形式,方便手动调试。在键值对后按 Enter 回车键自动智能生成补全提示
322+
{ // 这个对象还可以简化为 "int:2" 这种字符串形式,方便手动调试。在键值对后按 Enter 回车键自动智能生成补全提示
323323
"type": "long",
324324
"value": 2
325325
}
@@ -978,31 +978,42 @@
978978
var vRemember = document.getElementById("vRemember");
979979

980980
var lang = App == null ? null : App.language;
981-
vUrl.value = lang == CodeUtil.LANGUAGE_GO ? 'test.Divide.Divide' : 'unitauto.test.TestUtil.divide' //main.js里访问不到,可能是script引用顺序问题
981+
vUrl.value = lang == CodeUtil.LANGUAGE_GO ? 'test.Divide' : (lang == CodeUtil.LANGUAGE_PYTHON ? 'unitauto.test.testutil.divide' : 'unitauto.test.TestUtil.divide') //main.js里访问不到,可能是script引用顺序问题
982982
vInput.value = (lang == CodeUtil.LANGUAGE_GO ? `{
983983
"methodArgs": [
984-
{ // 可省略来自动判断的 type: bool,float64,string,map[string]any,[]any
984+
{ // 可省略来自动判断的 type: bool,float64,string,map[string]any,[]any
985985
"type": "int",
986986
"value": 1
987987
},
988-
{ // 这个对象还可以简化为 "int:2" 这种字符串形式,方便手动调试。在键值对后按 Enter 回车键自动智能生成补全提示
988+
{ // 这个对象还可以简化为 "int:2" 这种字符串形式,方便手动调试。在键值对后按 Enter 回车键自动智能生成补全提示
989+
"type": "int",
990+
"value": 2
991+
}
992+
]
993+
}` : (lang == CodeUtil.LANGUAGE_PYTHON ? `{
994+
"args": [
995+
{ // 可省略来自动判断的 type: bool,int,float,str,dict,list
996+
"type": "int",
997+
"value": 1
998+
},
999+
{ // 这个对象还可以简化为 "int:2" 这种字符串形式,方便手动调试。在键值对后按 Enter 回车键自动智能生成补全提示
9891000
"type": "int",
9901001
"value": 2
9911002
}
9921003
]
9931004
}` : `{
9941005
"static": true,
9951006
"methodArgs": [
996-
{ // 可省略来自动判断的 type: Boolean,Integer,BigDecimal,String,JSONObject,JSONArray
1007+
{ // 可省略来自动判断的 type: Boolean,Integer,BigDecimal,String,JSONObject,JSONArray
9971008
"type": "long",
9981009
"value": 1
9991010
},
1000-
{ // 这个对象还可以简化为 "int:2" 这种字符串形式,方便手动调试。在键值对后按 Enter 回车键自动智能生成补全提示
1011+
{ // 这个对象还可以简化为 "int:2" 这种字符串形式,方便手动调试。在键值对后按 Enter 回车键自动智能生成补全提示
10011012
"type": "long",
10021013
"value": 2
10031014
}
10041015
]
1005-
}`) + `
1016+
}`)) + `
10061017
10071018
/*
10081019
以上 JSON 文本支持 JSON5 格式。清空文本内容可查看规则。

UnitAuto-Go/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ UnitAuto Go Library for remote dependencies with GitHub repo, etc.
99
<img width="1495" alt="image" src="https://user-images.githubusercontent.com/5738175/225636134-a4daf4ec-9304-44d2-b09a-28497c815188.png">
1010
<img width="1495" alt="image" src="https://user-images.githubusercontent.com/5738175/225636569-b508fa19-3973-4655-bd49-68742c4d09d0.png">
1111

12+
**Demo:** https://github.com/TommyLemon/unitauto-go-demo
13+
1214
#### 1. 在 go.mod 中添加 GitHub 仓库
1315
#### 1. Add the GitHub repository to go.mod
1416
```go
@@ -42,3 +44,32 @@ https://github.com/TommyLemon/unitauto-go/blob/main/main.go
4244
<img width="1495" alt="image" src="https://user-images.githubusercontent.com/5738175/225632360-ce953a58-22b1-4b4e-8b3d-0083edebc71a.png">
4345
<img width="1495" alt="image" src="https://user-images.githubusercontent.com/5738175/225635146-f8dab9d1-76c5-421a-b45e-732e4923fd4d.png">
4446

47+
<br />
48+
49+
### 4. 关于作者
50+
### 4. Author
51+
[https://github.com/TommyLemon](https://github.com/TommyLemon)<br />
52+
<img width="1279" alt="image" src="https://user-images.githubusercontent.com/5738175/199979403-ace8b574-cd64-4582-8c19-b51571945214.png">
53+
54+
如果有什么问题或建议可以 [去 APIAuto 提 issue](https://github.com/TommyLemon/APIAuto/issues),交流技术,分享经验。<br >
55+
如果你解决了某些 bug,或者新增了一些功能,欢迎 [提 PR 贡献代码](https://github.com/Tencent/APIJSON/blob/master/CONTRIBUTING.md),感激不尽。
56+
<br />
57+
If you have any questions or suggestions, you can [create an issue](https://github.com/TommyLemon/APIAuto/issues). <br >
58+
If you can added a feature or fixed a bug, please [create a pull request](https://github.com/TommyLemon/unitauto-go/pulls), thank you~
59+
60+
61+
### 5. 其它项目
62+
### 5. Link
63+
创作不易、坚持更难,右上角点 ⭐ Star 支持下吧,谢谢 ^_^
64+
65+
[UnitAuto](https://github.com/TommyLemon/UnitAuto) 机器学习零代码单元测试平台,零代码、全方位、自动化 测试 方法/函数 的正确性、可用性和性能
66+
67+
[unitauto-go-demo](https://github.com/TommyLemon/unitauto-go-demo) UnitAuto Go Demo,提供用来做单元测试的业务函数
68+
69+
[unitauto-py](https://github.com/TommyLemon/unitauto-py) UnitAuto Python 库,可通过 pip 仓库等远程依赖
70+
71+
[APIJSON](https://github.com/Tencent/APIJSON) 🚀 腾讯零代码、全功能、强安全 ORM 库 🏆 后端接口和文档零代码,前端(客户端) 定制返回 JSON 的数据和结构
72+
73+
[APIAuto](https://github.com/TommyLemon/APIAuto) 敏捷开发最强大易用的 HTTP 接口工具,机器学习零代码测试、生成代码与静态检查、生成文档与光标悬浮注释,集 文档、测试、Mock、调试、管理 于一体的一站式体验
74+
75+
[SQLAuto](https://github.com/TommyLemon/SQLAuto) 智能零代码自动化测试 SQL 语句执行结果的数据库工具,任意增删改查、任意 SQL 模板变量、一键批量生成参数组合、快速构造大量测试数据

UnitAuto-Go/unitauto/method_util.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ var KEY_RETURN = "return"
7676
var KEY_TIME_DETAIL = "time:start|duration|end"
7777
var KEY_CLASS_ARGS = "classArgs"
7878
var KEY_METHOD_ARGS = "methodArgs"
79+
var KEY_ARGS = "args"
7980
var KEY_CALLBACK = "callback"
8081
var KEY_GLOBAL = "global"
8182

@@ -565,6 +566,16 @@ func InvokeMethod(req map[string]any, instance any, listener Listener[any]) erro
565566
var this_ = GetMap(req, KEY_THIS)
566567
var clsArgs = GetArgList(req, KEY_CLASS_ARGS)
567568
var methodArgs = GetArgList(req, KEY_METHOD_ARGS)
569+
var args = GetArgList(req, KEY_ARGS)
570+
if len(args) > 0 {
571+
if methodArgs != nil {
572+
err := errors.New(KEY_ARGS + " 和 " + KEY_METHOD_ARGS + " 不能同时传!")
573+
completeWithError(pkgName, clsName, methodName, startTime, err, listener)
574+
return err
575+
}
576+
577+
methodArgs = args
578+
}
568579

569580
if IsEmpty(cttName, true) && len(clsArgs) > 0 {
570581
err := errors.New("Go 没有构造函数,不允许单独传 " + KEY_CLASS_ARGS + " ,必须配合 " + KEY_CONSTRUCTOR + " 一起用!")

UnitAuto-Python/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,32 @@ if you cannot run the command successfully, try python3:
5454
#### 3. Test by following the main repo
5555

5656
https://github.com/TommyLemon/UnitAuto
57+
58+
<br />
59+
60+
### 4. 关于作者
61+
### 4. Author
62+
[https://github.com/TommyLemon](https://github.com/TommyLemon)<br />
63+
<img width="1279" alt="image" src="https://user-images.githubusercontent.com/5738175/199979403-ace8b574-cd64-4582-8c19-b51571945214.png">
64+
65+
如果有什么问题或建议可以 [去 APIAuto 提 issue](https://github.com/TommyLemon/APIAuto/issues),交流技术,分享经验。<br >
66+
如果你解决了某些 bug,或者新增了一些功能,欢迎 [提 PR 贡献代码](https://github.com/Tencent/APIJSON/blob/master/CONTRIBUTING.md),感激不尽。
67+
<br />
68+
If you have any questions or suggestions, you can [create an issue](https://github.com/TommyLemon/APIAuto/issues). <br >
69+
If you can added a feature or fixed a bug, please [create a pull request](https://github.com/TommyLemon/unitauto-py/pulls), thank you~
70+
71+
<br />
72+
73+
### 5. 其它项目
74+
### 5. Link
75+
创作不易、坚持更难,右上角点 ⭐ Star 支持下吧,谢谢 ^_^
76+
77+
[UnitAuto](https://github.com/TommyLemon/UnitAuto) 机器学习零代码单元测试平台,零代码、全方位、自动化 测试 方法/函数 的正确性、可用性和性能
78+
79+
[unitauto-go](https://github.com/TommyLemon/unitauto-go) UnitAuto Go 库,可通过 GitHub 仓库等远程依赖
80+
81+
[APIJSON](https://github.com/Tencent/APIJSON) 🚀 腾讯零代码、全功能、强安全 ORM 库 🏆 后端接口和文档零代码,前端(客户端) 定制返回 JSON 的数据和结构
82+
83+
[APIAuto](https://github.com/TommyLemon/APIAuto) 敏捷开发最强大易用的 HTTP 接口工具,机器学习零代码测试、生成代码与静态检查、生成文档与光标悬浮注释,集 文档、测试、Mock、调试、管理 于一体的一站式体验
84+
85+
[SQLAuto](https://github.com/TommyLemon/SQLAuto) 智能零代码自动化测试 SQL 语句执行结果的数据库工具,任意增删改查、任意 SQL 模板变量、一键批量生成参数组合、快速构造大量测试数据

UnitAuto-Python/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
def callback():
77
pass
88

9+
# methodutil.config.DEFAULT_MODULE_PATH = "unitauto"
910
# methodutil.listener.callback = callback
1011

1112
test()

0 commit comments

Comments
 (0)