rogerxu / rogerxu.github.io

Roger Xu's Blog
3 stars 2 forks source link

JMeter #190

Open rogerxu opened 6 years ago

rogerxu commented 6 years ago

Apache JMeter - Apache JMeter™

rogerxu commented 6 years ago

Variables

Apache JMeter - User's Manual: Functions and Variables

Variable

Apache JMeter - User's Manual: Elements of a Test Plan

${VARIABLE}

Property

__property

__P

rogerxu commented 6 years ago

Maven

jmeter-maven-plugin/jmeter-maven-plugin: The JMeter Maven Plugin

<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>
        <generateReports>false</generateReports>
        <resultsFileFormat>xml</resultsFileFormat>
        <proxyConfig>
            <host>proxy</host>
            <port>8080</port>
            <hostExclusions>localhost|*.example.com</hostExclusions>
        </proxyConfig>
        <propertiesUser>
            <threads>${threads}</threads>
            <loops>${loops}</loops>
            <serviceHost>${serviceHost}</serviceHost>
        </propertiesUser>
    </configuration>
</plugin>
$ mvn clean verify -P PT-Test -Dthreads=3 -Dloops=10 -DservcieHost=www.host.com

Generate *.jtl for Test Results File

Test Results File Format · jmeter-maven-plugin/jmeter-maven-plugin Wiki · GitHub

https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/blob/e5ef94b6c300e23ac182c51b40dc7b293313e8ff/src/main/java/com/lazerycode/jmeter/mojo/ConfigureJMeterMojo.java#L428-L436

    protected void setJMeterResultFileFormat() {
        if (generateReports || "csv".equalsIgnoreCase(resultsFileFormat)) {
            propertiesJMeter.put("jmeter.save.saveservice.output_format", "csv");
            resultsOutputIsCSVFormat = true;
        } else {
            propertiesJMeter.put("jmeter.save.saveservice.output_format", "xml");
            resultsOutputIsCSVFormat = false;
        }
    }