我正试图在我的项目中以编程方式运行run插件。我使用的是maven嵌入器System.setProperty("maven.multiModuleProjectDirectory",".\");MavenCli cli =新的MavenCli();
cli.doMain(new String[]{"com.lazerycode.jmeter:jmeter-maven-plugin:3.6.1:configure"}, ".\\", System.out, System.out);
cli.doMain(new String[]{"com.lazerycode.jmeter:jmeter-maven-plugin:3.6.1:jmeter"}, ".\\", System.out, System.out);执行此操作时,日志不会显示任何内容。
当我在IntelliJ中手动使用插件时,我使用插件,->,j抄,->,and:->,或者as :and,我没有遇到这个问题,我没有得到预期的日志。怎么一回事?
发布于 2022-10-06 09:41:51
为了“查看”日志,您需要在项目Sl4j-简单中拥有相关版本的依赖关系库。
也可能是这样,“日志”转到斯泰尔,您将它重定向到标准输出,这样输出的流就无处可去了
下面是示例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>org.example</groupId>
<artifactId>jmeter-maven-embedder</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
<version>3.8.6</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>3.8.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.36</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>3.6.1</version>
<executions>
<!-- Generate JMeter configuration -->
<execution>
<id>configuration</id>
<goals>
<goal>configure</goal>
</goals>
</execution>
<!-- Run JMeter tests -->
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
<!-- Fail build on errors in test -->
<execution>
<id>jmeter-check-results</id>
<goals>
<goal>results</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>下面是一个例子调用:
import org.apache.maven.cli.MavenCli;
public class JMeterRunner {
public static void main(String[] args) {
String basedir = "/path/to/the/folder/with/pom.xml";
System.setProperty("maven.multiModuleProjectDirectory", basedir);
MavenCli cli = new MavenCli();
cli.doMain(new String[]{"clean", "verify"}, basedir, System.out, System.err);
}
}更多信息:如何使用JMeter Maven插件
https://stackoverflow.com/questions/73963448
复制相似问题