drools8尝试(加单元测试)

drools8的maven模板项目里没有单元测试, 相比而言drools7有个非常好的test senorios

那就自己弄一个

文件是.http后缀的,写了个简单的例子如下

powershell 复制代码
//测试交通违章
POST  http://localhost:8080/Traffic Violation
accept: application/json
Content-Type: application/json

{
  "Violation": {
    "Code": "zzfdsfz",
    "Date": "2023-08-23",
    "Type": "speed",
    "Speed Limit": 10,
    "Actual Speed": 100
  },
  "Driver": {
    "Name": "string",
    "Age": 0,
    "State": "string",
    "City": "string",
    "Points": 0
  }
}

> {%
// 这块是对结果的测试
client.test("Request executed successfully", function() {
  client.assert(response.status === 200, "Response status is not 200");
  //client.assert(response.status === 203, "Response status is  200");
  //意思是说,罚金恒等于1000  否则报错"罚金计算错误"
  client.assert(response.body.Fine.Amount === 1000, "罚金计算错误");

});
%}

感觉还不错

下一步应用到k8s里,或者是看原生的微服务是什么东西

相关推荐
Tony Bai1 天前
【Go 测试之道】03 单元测试(下):HTTP 层的黑盒守护与依赖注入
单元测试
IMPYLH2 天前
Lua 的 collectgarbage 函数
开发语言·笔记·junit·单元测试·lua
IMPYLH2 天前
Lua 的 assert 函数
开发语言·笔记·junit·单元测试·lua
Jonathan Star3 天前
前端需要做单元测试吗?哪些适合做?
前端·单元测试·状态模式
u***u6853 天前
前端组件单元测试模拟,Jest mock函数
前端·单元测试
清晰-简洁3 天前
Spring Boot 单元测试按需加载
spring boot·后端·单元测试
q***42053 天前
Spring Boot 整合 log4j2 日志配置教程
spring boot·单元测试·log4j
阿智智4 天前
用Maven的quickstart archetype创建项目并结合JUnit5单元测试
java·单元测试·maven·junit5
G***66914 天前
前端组件单元测试覆盖率,目标与实现
前端·单元测试
天天进步20154 天前
前端单元测试从入门到精通:Jest与Testing Library实战
前端·单元测试