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 => {