Premise
MAVEN is already installed on window and MAVEN is configured in Eclipse, if not configured, refer to the article installing MAVEN on Windows and configuring Maven in Eclipse
First, create a MAVEN project that contains jmeter scripts
1. Open Eclipse, top left file, new--Other maven----maven----Next
2. Select Use default Workspace location, next
3. Select Maven-archetype-quickstart, Next
4. Fill in the group ID, Artifact ID, Version, package, and click Done
Build a successful project directory as follows
Second, the MAVEN default file storage structure
We create a JMeter folder under the Src/test file directory and put the JMeter script under that directory
Third, configuration Pom.xml file
This is the latest Jmeter-maven-plugin plug-in version <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.test.autoTest</groupId> <Artifactid>AutoTest</Artifactid> <version>0.0.1-snapshot</version> <Packaging>Jar</Packaging> <name>AutoTest</name> <URL>http://maven.apache.org</URL> <Properties> <Project. build.sourceencoding>UTF-8</project.build.sourceEncoding> </Properties> <Dependencies> <Dependency> <groupId>Junit</groupId> <Artifactid>Junit</Artifactid> <version>3.8.1</version> <Scope>Test</Scope> </Dependency> </Dependencies> <Build> <Plugins> <plugin> <groupId>Com.lazerycode.jmeter</groupId> <Artifactid>Jmeter-maven-plugin</Artifactid> <version>2.7.0</version> <executions> <Execution> <ID>Jmeter-tests</ID> <Phase>Verify</Phase> <Goals> <goal>Jmeter</goal> </Goals> </Execution> </executions> <Configuration>
<!--Select the script to execute--
<testfilesincluded> <Jmetertestfile>Hdwyyz.jmx</Jmetertestfile> </testfilesincluded> <!--report file tail output time - <Appendresultstimestamp>True</Appendresultstimestamp> </Configuration> </plugin> </Plugins> <Defaultgoal>Compile</Defaultgoal> </Build></Project>
Iv. running the project
Right-click Pom.xml, run as MAVEN build, configure MAVEN Build
Goals:verify, click Run, Jmeter-maven-plugin plugin will automatically introduce JMeter class library
Display on console after successful run
Many files are generated automatically under the target folder
Specific results are shown under Jmeter/logs, Jmeter/reports, and Jmeter/results
V. Problems encountered and Solutions
1. When compiling the MAVEN project, [ERROR] No compiler is provided in this environment. Perhaps is running on a JRE rather than a JDK?
WORKAROUND: You do not need to modify the settings.xml in the Conf folder in Maven
about the MAVEN project build occurs when no compiler is provided in the This environment processing
2. "No goals has been specifiedfor this build" appears when compiling MAVEN project
Workaround: Add <defaultGoal>compile</defaultGoal> after pom.xml files <build> tags
Vi. references
jmeter-maven-plugin Trial Notes maven+jmeter+jenkins integrated jmeter-maven-plugin use, and JMeter integration with Jenkins Advanced Configuration--Select test script
Windows:jmeter Automated Test-eclipse+maven+jmeter