JMeter 4.0 中的要求非常简单。在jmeter中运行简单的测试,如果失败则发送电子邮件。所以我有这个:
>ThreadGroup
>Http Request
>Response Assertion
>Summary Report
>BeanShell Listener
>If Controller
>SMTP Sampler
Run Code Online (Sandbox Code Playgroud)
因此,练习 SMTP 采样器的最佳方法似乎是使用 JMeterThread.last_sample_ok 变量。我正在 BeanShell Listener 中测试这个变量并且它有效。如果我关闭正在测试的 REST 服务,我可以看到该变量为 false,如果我启动该服务,它会返回 true。完美的。在 If 控制器中,当我输入 JMeterThread.last_sample_ok 时,我会在服务开启时收到一封电子邮件。太棒了...按其应有的方式工作。问题:当我关闭服务导致断言失败并将 If 控制器更改为相反的值:!JMeterThread.last_sample_ok 时,我从未收到电子邮件。当预期断言失败时,If 控制器似乎永远不会响应,而且我从未收到电子邮件。我可以证明该变量在 BeanShell 侦听器中正确转换...我可以看到在失败情况下,!JMeterThread.last_sample_ok 转换为“true”,因此 If 控制器中的相同代码应该可以工作。我究竟做错了什么?这是 XML 文件...
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="4.0" jmeter="4.0 r1823414">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp> …Run Code Online (Sandbox Code Playgroud) 我在这方面做了很多阅读。看起来非常的正直。如果您看到 pom 文件,您可以看到它不是从远程 URL 创建类文件,而是该文件必须是项目的一部分。注释掉的配置有效...找到 WSDL 并创建正确的文件。当我尝试在本地驱动它时,没有任何效果。我展示的版本是我尝试使用 maven ${project.basedir} 变量的地方。我尝试过“/src/main/java”、“src/main/java”,对路径进行硬编码。我该怎么做呢?我已经尝试了我看到的所有示例。这是我的 pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>abc</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>abc</name>
<description>consume soap</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.12.3</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>com.mycompany.abc.domain</packageName>
<wsdl>true</wsdl>
<xmlschema>false</xmlschema>
<schemaFiles>abc.wsdl</schemaFiles>
<schemaDirectory>${project.basedir}/src/main/resources</schemaDirectory>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
<clearOutputDir>true</clearOutputDir>
</configuration> …Run Code Online (Sandbox Code Playgroud)