SkillAgentSearch skills...

UnitAuto

☀️ 最先进、最省事、ROI 最高的单元测试,机器学习 零代码、全方位、自动化 测试 方法/函数,用户包含腾讯、快手、某 500 强巨头等 ☀️ 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.

Install / Use

/learn @TommyLemon/UnitAuto

README

<h1 align="center" style="text-align:center;"> UnitAuto </h1> <p align="center">☀️ 机器学习零代码单元测试平台</p> <p align="center">零代码、全方位、自动化 测试 方法/函数 的正确性、可用性和性能</p> <p align="center" > <a href="https://github.com/TommyLemon/UnitAuto/tree/master/UnitAuto-Java-Demo"><img src="https://img.shields.io/badge/Java-1.8%2B-brightgreen.svg?style=flat"></a> <a href="https://github.com/TommyLemon/UnitAuto/tree/master/UnitAuto-Java-Demo"><img src="https://img.shields.io/badge/Kotlin-1.2%2B-brightgreen.svg?style=flat"></a> <a href="https://github.com/TommyLemon/UnitAuto/tree/master/UnitAuto-Go"><img src="https://img.shields.io/badge/Go-1.18%2B-brightgreen.svg?style=flat"></a> <a href="https://github.com/TommyLemon/UnitAuto/tree/master/UnitAuto-Python"><img src="https://img.shields.io/badge/Python-3.7%2B-brightgreen.svg?style=flat"></a> <a href="https://github.com/TommyLemon/UnitAuto/tree/master/UnitAuto-CPP"><img src="https://img.shields.io/badge/C%2B%2B-17%2B-brightgreen.svg?style=flat"></a> <a href="https://github.com/TommyLemon/UnitAuto/tree/master/UnitAuto-Android"><img src="https://img.shields.io/badge/Android-26%2B-brightgreen.svg?style=flat"></a> </p> <p align="center" > <a href="https://github.com/TommyLemon/UnitAuto#%E9%9B%86%E6%88%90%E5%88%B0%E8%A2%AB%E6%B5%8B%E9%A1%B9%E7%9B%AE">使用文档</a> <a href="https://search.bilibili.com/all?keyword=UnitAuto">视频教程</a> <a href="http://apijson.cn/unit">在线体验</a> <a href="https://deepwiki.com/TommyLemon/UnitAuto">AI 问答</a> </p> <p align="center" > <img src="https://raw.githubusercontent.com/TommyLemon/UnitAuto/master/UnitAuto-Admin/img/logo.png" /> </p>

机器学习零代码单元测试平台,零代码、全方位、自动化 测试 方法/函数 的正确性、可用性和性能。<br /> 用户包含 腾讯 IEG 互动娱乐事业群、腾讯 WXG 微信事业群、快手广告、某市值 4000亿+ 500 强巨头 等。

已被 互联网教育智能技术及应用国家工程实验室 收录。 https://github.com/TommyLemon/APIAuto/issues/19

<img width="1495" alt="image" src="https://user-images.githubusercontent.com/5738175/221088793-f60d1a43-fdb4-4cda-84ef-04fdee1aa472.png"> <img width="1495" alt="image" src="https://raw.githubusercontent.com/TommyLemon/StaticResources/master/UnitAuto/UnitAuto-RandomTest-Parent-small.jpg"> <img width="1495" alt="image" src="https://user-images.githubusercontent.com/5738175/224038704-fef31759-c349-40cb-a252-e0c8cff55110.png"> <img width="1495" alt="image" src="https://github.com/TommyLemon/UnitAuto/assets/5738175/4c643a5a-b693-42a1-bb55-3eee61b97f2a"> <img width="1495" alt="image" src="https://github.com/TommyLemon/UnitAuto/assets/5738175/12b2a81b-bc41-413c-b748-956bbdec7409"> <img width="1495" alt="image" src="https://github.com/TommyLemon/UnitAuto/assets/5738175/842e1783-abc7-4cae-aaa5-f7693c69b4ce">

特点优势

相比 JUnit, JTest, Mockito, Mockk 等一堆 Compiling testing 工具:<br /> 1.其它工具需要每个方法都写一大堆测试代码,需要开发成本、需要解决测试代码的 bug、业务代码更改后需要同步修改测试代码等;<br /> UnitAuto 不需要写任何代码,直接读取方法的属性,自动注入参数,拿到返回值和类成员变量,机器学习自动化校验。<br /> <br /> 2.UnitAuto 这种 Runtime testing 工具无需 Mock 环境(Application, Context 等),<br /> 更不用为 无法有效地 Mock 环境相关类、第三方登录未提供 Mock 支持 等而头疼,<br /> 只要被测方法满足 有 return 值、有 interface 回调、改变成员变量 field 这 3 点中至少一点就能测。

腾讯内先后被 微信支付部门、IEG 工具开发组、CDG 金融支付组、IEG PC 游戏平台部 邀请分享了

  • 零代码测试工具与实践(API•单元•UI)
  • 零代码开发和测试(API测试•单元测试•API开发)
  • 零代码开发和测试(API测试•单元测试•API开发)
  • 零代码开发和测试(接口测试•单元测试•接口开发)

质效无双线上技术访谈-零代码智能测试工具实践介绍-第11期

https://testwo.cn1.quickconnect.cn/vs/sharing/iiP8VK1C#!aG9tZV92aWRlby0xMQ== https://testwo.cn1.quickconnect.cn/vs/sharing/iiP8VK1C#!aG9tZV92aWRlby0xMQ==

<br /> <br />

原理说明

被测项目不需要写任何单元测试代码(逻辑代码、注解代码等全都不要),<br /> UnitAuto 会自动生成测试参数,并执行方法,拿到返回值等进行校验。<br /> 泛型、接口等自动模拟,异步执行方法自动记录回调过程,都是零代码。<br /> <br /> UnitAuto-Admin 是类似 APIAuto 的机器学习零代码测试工具(查看、上传、执行、测试 后端项目中的方法等),<br /> UnitAuto-Java 提供扫描所有方法、执行某个方法两个 API (主要引入 MethodUtil.java 这个类,里面已实现)。<br /> <br />

通过扫描项目中的可访问的 package, class, method 来生成和导入测试用例
<p align="center" > <a ><img src="https://raw.githubusercontent.com/TommyLemon/StaticResources/master/UnitAuto/UnitAuto-Method-List-small.jpg"></a> </p> <br />
HTTP 远程调用被测服务/App,转至内部 构造/获取 实例来 invoke 动态执行方法
<p align="center" > <a ><img src="https://user-images.githubusercontent.com/5738175/87251324-6b759900-c49d-11ea-8468-aaf26124b7e0.png"></a> </p> <br />
获取参数、成员变量等前后状态,拦截方法被调用过程并可视化展示
<p align="center" > <a ><img src="https://raw.githubusercontent.com/TommyLemon/StaticResources/master/UnitAuto/UnitAuto-Test-interface-small.jpg"></a> </p> <br />
通过简单配置自动调整参数组合,拿到返回结果后通过 前后结果对比 或 机器学习校验模型 来自动断言
<p align="center" > <a ><img src="https://raw.githubusercontent.com/TommyLemon/StaticResources/master/UnitAuto/UnitAuto-RandomTest-Parent-small.jpg"></a> </p> <p align="center" > <a ><img src="https://raw.githubusercontent.com/TommyLemon/StaticResources/master/UnitAuto/UnitAuto-RandomTest-Child-small.jpg"></a> </p> <br />
后端不再需要像以下示例一样编写和维护大量单元测试用例代码(逻辑代码、注解代码等):
<p align="center" > <a ><img src="https://raw.githubusercontent.com/TommyLemon/StaticResources/master/UnitAuto/UnitAuto-Compare-Code-small.jpg"></a> </p> <br />
客户端可作为 HTTP Server 来为 UnitAuto 网页工具 提供远程调用的接口,效果同样:
<p align="center" > <a ><img src="https://user-images.githubusercontent.com/5738175/87251324-6b759900-c49d-11ea-8468-aaf26124b7e0.png"></a> </p> <p align="center" > <a ><img src="https://user-images.githubusercontent.com/5738175/87251395-f5bdfd00-c49d-11ea-809f-3c7330d7b6e1.png"></a> </p> <br /> <br />

示例项目

UnitAuto Java 后端 Server 在线 测试 <br /> APIJSON Java 后端 Server 在线 测试 <br /> UnitAuto Android 客户端 App 直接 下载 (第一次可能失败,返回报错 JSON,一般重试一次就可以)<br /> APIJSON Android 客户端 App 直接 下载 (第一次可能失败,返回报错 JSON,一般重试一次就可以) <br /> <br />

演讲视频

UnitAuto-机器学习自动化单元测试平台简介 <br /> https://www.bilibili.com/video/BV1Tk4y1R7Yo <br /> <br /> UnitAuto-异步回调方法的零代码单元测试 <br /> https://www.bilibili.com/video/BV1kk4y1z7bW <br />

其它 https://search.bilibili.com/all?keyword=UnitAuto <br />

集成到被测项目

Java 后端 Server

1.依赖 unitauto.jar

放到你 启动 Application 所在项目的 libs 目录,然后 Eclipse Add to Build Path 或 Idea Add as Library <br /> https://github.com/TommyLemon/UnitAuto/tree/master/UnitAuto-Java-Demo/libs <br /> <br />

2.依赖 unitauto-jar.jar

如果不打 jar/war 包,则可以跳过这个步骤。<br /> 依赖方式同步骤 1。<br /> https://github.com/TommyLemon/UnitAuto/tree/master/UnitAuto-Java-Demo/libs <br /> 依赖后需要在 Application static 代码块 中初始化

    static {
        UnitAutoApp.init();
    }
<br />
3.提供接口给 UnitAuto 后台管理工具

Controller 提供两个 POST application/json 格式的 HTTP API,分别是

/method/list    动态扫描方法,可以单纯接收入参并转发到 MethodUtil.listMethod(String request)
/method/invoke  动态执行方法,可以单纯接收入参并转发到 MethodUtil.invokeMethod(String request, Object instance, Listener<JSONObject> listener)

参考 DemoController <br /> <br />

4.配置环境相关类及自定义处理逻辑

拦截 MethodUtil 类中的 INSTANCE_GETTER, JSON_CALLBACK, CLASS_LOADER_CALLBACK 等 interface 的回调方法,<br /> 可以支持获取 Context 等环境相关类的实例、转 JSON 对象时过滤特定类、其它自定义逻辑处理,参考 DemoApplication<br /> <br /><br />

Android 客户端 App

1.依赖 UnitAuto-Apk

UnitAuto-Apk 导入到你项目 app moudule 所在目录settings.gradle

include ':UnitAuto-Apk'

app moudule 目录build.gradle

dependencies {
    api project(':UnitAuto-Apk')
}
<br />
2.初始化 UnitAuto

Application onCreate 方法 中初始化

    @Override
    public void onCreate() {
        super.onCreate();
        UnitAutoApp.init(this);
    }
<br />
3.提供 UnitAuto 管理界面入口

AndroidManifest.xml 中注册 UnitAutoActivity

<manifest ... >
    <application ... >
      
        <activity
            android:name="unitauto.apk.UnitAutoActivity"
            android:launchMode="singleInstance">
        </activity>
      
     </application>
</manifest>

可在你项目的任何界面新增一个按钮或其它形式的入口,仅 DEBUG 模式下展示

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="onClickUnit"
        android:text="UnitAutoAct
View on GitHub
GitHub Stars265
CategoryDevelopment
Updated3d ago
Forks58

Languages

JavaScript

Security Score

100/100

Audited on Mar 29, 2026

No findings