Skip to content

Selecting Tests To Run

Mark Collin edited this page Jan 18, 2014 · 8 revisions

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>1.9.0</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <phase>verify</phase>
                            <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>1.9.0</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                            <configuration>
                                <testFilesIncluded>
                                    <jMeterTestFile>test1.jmx</jMeterTestFile>
                                    <jMeterTestFile>test2.jmx</jMeterTestFile>
                                </testFilesIncluded>
                            </configuration>
                        </execution>
                    </executions>
                </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>1.9.0</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                            <configuration>
                                <testFilesIncluded>
                                    <jMeterTestFile>foo*.jmx</jMeterTestFile>
                                </testFilesIncluded>
                            </configuration>
                        </execution>
                    </executions>
                </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>1.9.0</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                            <configuration>
                                <testFilesExcluded>
                                    <excludeJMeterTestFile>test3.jmx</excludeJMeterTestFile>
                                    <excludeJMeterTestFile>test4.jmx</excludeJMeterTestFile>
                                </testFilesExcluded>
                            </configuration>
                        </execution>
                    </executions>
                </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>1.9.0</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                            <configuration>
                                <testFilesExcluded>
                                    <excludeJMeterTestFile>*bar.jmx</excludeJMeterTestFile>
                                </testFilesExcluded>
                            </configuration>
                        </execution>
                    </executions>
                </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>1.9.0</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                            <configuration>
                                <testFilesDirectory>/scratch/testfiles/</testFilesDirectory>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    [...]
</project>
+---+