Jmeter-Maven-Plugin高级应用:Selecting Tests To Run

地址:https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/wiki/Advanced-Configuration

Selecting Tests To Run


 

Running All Tests

To run all tests held in the ${project.base.directory}/src/test/jmeter you just need to run the phase you have assigned to the execution phase.

In the example below the execution phase has been set to verify:

+---+
<project>
    [...]
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId> <artifactId>jmeter-maven-plugin</artifactId> <version>2.0.3</version> <executions> <execution> <id>jmeter-tests</id> <goals> <goal>jmeter</goal> </goals> </execution> </executions> </plugin> </plugins> </build> [...] </project> +---+

So to run all the tests type:

mvn verify

 

Specifying <testFilesIncluded>

You can explicitly specify which tests in the ${project.base.directory}/src/test/jmeter should be run by using the <jMeterTestFiles> tag:

+---+
<project>
    [...]
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId> <artifactId>jmeter-maven-plugin</artifactId> <version>2.0.3</version> <executions> <execution> <id>jmeter-tests</id> <goals> <goal>jmeter</goal> </goals> </execution> </executions> <configuration> <testFilesIncluded> <jMeterTestFile>test1.jmx</jMeterTestFile> <jMeterTestFile>test2.jmx</jMeterTestFile> </testFilesIncluded> </configuration> </plugin> </plugins> </build> [...] </project> +---+

This time when you type mvn verify only test1.jmx and test2.jmx will be run.

 

Specifying <testFilesIncluded> Using Regex

You can also use a regex to specify which tests to include, below is a simple example showing how to include all tests starting with the text foo:

+---+
<project>
    [...]
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId> <artifactId>jmeter-maven-plugin</artifactId> <version>2.0.3</version> <executions> <execution> <id>jmeter-tests</id> <goals> <goal>jmeter</goal> </goals> </execution> </executions> <configuration> <testFilesIncluded> <jMeterTestFile>foo*.jmx</jMeterTestFile> </testFilesIncluded> </configuration> </plugin> </plugins> </build> [...] </project> +---+

 

Specifying <testFilesExcluded>

Rather than specifying which tests should be run, you could alternatively specify which tests in the ${project.base.directory}/src/test/jmeter you do not wish to run by using the <excludeJMeterTestFiles> tag:

+---+
<project>
    [...]
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId> <artifactId>jmeter-maven-plugin</artifactId> <version>2.0.3</version> <executions> <execution> <id>jmeter-tests</id> <goals> <goal>jmeter</goal> </goals> </execution> </executions> <configuration> <testFilesExcluded> <excludeJMeterTestFile>test3.jmx</excludeJMeterTestFile> <excludeJMeterTestFile>test4.jmx</excludeJMeterTestFile> </testFilesExcluded> </configuration> </plugin> </plugins> </build> [...] </project> +---+

This time when you type mvn verify all tests in the tests in the${project.base.directory}/src/test/jmeter apart from test3.jmx and test4.jmx will be run.

 

Specifying <testFilesExcluded> Using Regex

You can also use a regex to specify which tests to exclude, below is a simple example showing how to include all tests ending with the text bar:

+---+
<project>
    [...]
<build>
    <plugins>
        <plugin>
            <groupId>com.lazerycode.jmeter</groupId> <artifactId>jmeter-maven-plugin</artifactId> <version>2.0.3</version> <executions> <execution> <id>jmeter-tests</id> <goals> <goal>jmeter</goal> </goals> </execution> </executions> <configuration> <testFilesExcluded> <excludeJMeterTestFile>*bar.jmx</excludeJMeterTestFile> </testFilesExcluded> </configuration> </plugin> </plugins> </build> [...] </project> +---+

 

Specifying The <testFilesDirectory>

You can specify the directory where the test files are located in your file system (by default the plugin will assume they are in ${project.base.directory}/src/test/jmeter)

+---+
<project>
    [...]
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId> <artifactId>jmeter-maven-plugin</artifactId> <version>2.0.3</version> <executions> <execution> <id>jmeter-tests</id> <goals> <goal>jmeter</goal> </goals> </execution> </executions> <configuration> <testFilesDirectory>/scratch/testfiles/</testFilesDirectory> </configuration> </plugin> </plugins> </build> [...]

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值