From 6b443008cda76d15e35ea95c0a9862d69eef4f5e Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Wed, 11 Nov 2020 12:08:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9C=BA=E6=99=AF=E7=BA=A7=E5=88=AB=E6=96=AD?= =?UTF-8?q?=E8=A8=80=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/scenario/Scenario.java | 2 + .../components/api/test/ApiTestConfig.vue | 39 ++-- .../api/test/components/ApiScenarioForm.vue | 7 +- .../components/assertion/ApiAssertions.vue | 209 +++++++++--------- .../api/test/model/ScenarioModel.js | 16 +- 5 files changed, 149 insertions(+), 124 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/Scenario.java b/backend/src/main/java/io/metersphere/api/dto/scenario/Scenario.java index c66d3df040..e245cbdc09 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/Scenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/Scenario.java @@ -1,5 +1,6 @@ package io.metersphere.api.dto.scenario; +import io.metersphere.api.dto.scenario.assertions.Assertions; import io.metersphere.api.dto.scenario.request.Request; import lombok.Data; @@ -15,6 +16,7 @@ public class Scenario { private List variables; private List headers; private List requests; + private Assertions assertions; private DubboConfig dubboConfig; private TCPConfig tcpConfig; private List databaseConfigs; diff --git a/frontend/src/business/components/api/test/ApiTestConfig.vue b/frontend/src/business/components/api/test/ApiTestConfig.vue index b53019010a..d4462a8eea 100644 --- a/frontend/src/business/components/api/test/ApiTestConfig.vue +++ b/frontend/src/business/components/api/test/ApiTestConfig.vue @@ -76,28 +76,28 @@ diff --git a/frontend/src/business/components/api/test/model/ScenarioModel.js b/frontend/src/business/components/api/test/model/ScenarioModel.js index f13525ea02..d6a29fdf21 100644 --- a/frontend/src/business/components/api/test/model/ScenarioModel.js +++ b/frontend/src/business/components/api/test/model/ScenarioModel.js @@ -1,5 +1,6 @@ import { Arguments, + ConstantTimer as JMXConstantTimer, CookieManager, DNSCacheManager, DubboSample, @@ -10,22 +11,24 @@ import { HTTPSamplerArguments, HTTPsamplerFiles, HTTPSamplerProxy, + IfController as JMXIfController, JDBCDataSource, JDBCSampler, JSONPathAssertion, JSONPostProcessor, + JSR223Assertion, JSR223PostProcessor, JSR223PreProcessor, RegexExtractor, ResponseCodeAssertion, ResponseDataAssertion, ResponseHeadersAssertion, + TCPSampler, TestElement, TestPlan, ThreadGroup, + XPath2Assertion, XPath2Extractor, - IfController as JMXIfController, - ConstantTimer as JMXConstantTimer, TCPSampler, JSR223Assertion, XPath2Assertion, } from "./JMX"; import Mock from "mockjs"; import {funcFilters} from "@/common/js/func-filter"; @@ -226,6 +229,7 @@ export class Scenario extends BaseConfig { this.enable = true; this.databaseConfigs = []; this.tcpConfig = undefined; + this.assertions = undefined; this.set(options); this.sets({ @@ -242,6 +246,7 @@ export class Scenario extends BaseConfig { options.databaseConfigs = options.databaseConfigs || []; options.dubboConfig = new DubboConfig(options.dubboConfig); options.tcpConfig = new TCPConfig(options.tcpConfig); + options.assertions = new Assertions(options.assertions); return options; } @@ -1151,6 +1156,9 @@ class JMXGenerator { this.addScenarioCookieManager(threadGroup, scenario); this.addJDBCDataSources(threadGroup, scenario); + + this.addAssertion(threadGroup, scenario); + scenario.requests.forEach(request => { if (request.enable) { if (!request.isValid()) return; @@ -1175,7 +1183,7 @@ class JMXGenerator { this.addRequestExtractor(sampler, request); - this.addRequestAssertion(sampler, request); + this.addAssertion(sampler, request); this.addJSR223PreProcessor(sampler, request); @@ -1467,7 +1475,7 @@ class JMXGenerator { httpSamplerProxy.add(new HTTPsamplerFiles(files)); } - addRequestAssertion(httpSamplerProxy, request) { + addAssertion(httpSamplerProxy, request) { let assertions = request.assertions; if (assertions.regex.length > 0) { assertions.regex.filter(this.filter).forEach(regex => {