Unkown lifecycle error in Maven when attempt to run Jmeter tests

43 views Asked by At

Hello i have been trying to run my jmeter script in maven and i keep getting this unknown lifecycle error, even though my POM.xml file seems to be correct.

Can someone please help me out and let me know what im doing wrong. Im running the MV commad listed below which references properties i have defined in my POM.xml. When i run the jmx file directly in Jmeter, it runs fine. But when attempting to run it in Maven locally, thats when I run into this error.

MVN Command:

mvn clean verify -e -Dtest.testcasename=Security4 -Dtest.environment=AllTests -Dtest.product=AllAPIs

MVN Error message:

INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.489 s
[INFO] Finished at: 2023-10-19T12:15:32-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase ".testcasename=Security4". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
org.apache.maven.lifecycle.LifecyclePhaseNotFoundException: Unknown lifecycle phase ".testcasename=Security4". You must specify a valid lifecycle phase or a goal 

POM.xml file:

    <?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>com.mycompany.app</groupId>

    <artifactId>Service</artifactId>

    <packaging>jar</packaging>

    <version>1.0-SNAPSHOT</version>

    <name>DPHTest</name>

    <description>This application contains the Jmeter Service Tests for my app.</description>

 

    <properties>

        <Environment>${test.environment}</Environment>

        <!--<Region>${test.region}</Region>-->

        <Server>${test.server}</Server>

        <Product>${test.product}</Product>

        <TestCaseName>${test.testcasename}</TestCaseName>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <maven.compiler.source>1.8</maven.compiler.source>

        <maven.compiler.target>1.8</maven.compiler.target>

    </properties>

 

    <dependencies>

        <!-- https://mvnrepository.com/artifact/junit/junit -->

        <dependency>

            <groupId>junit</groupId>

            <artifactId>junit</artifactId>

            <version>4.13.1</version>

            <scope>test</scope>

        </dependency>

    </dependencies>

 

    <build>

        <plugins>

            <plugin>

                <groupId>com.lazerycode.jmeter</groupId>

                <artifactId>jmeter-maven-plugin</artifactId>

                <version>3.5.0</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>

                <configuration>

                    <jmeterVersion>5.4.3</jmeterVersion>

                    <testPlanLibraries>

                        <artifact>org.apache.logging.log4j:log4j-core:2.17.0</artifact>

                    </testPlanLibraries>

                    <failBuildIfResultFileIsEmpty>false</failBuildIfResultFileIsEmpty>

                    <testFilesIncluded>

                        <!-- <jMeterTestFile>Security4.jmx</jMeterTestFile>   -->

                        <jMeterTestFile>${testcasename}.jmx</jMeterTestFile>

                    </testFilesIncluded>

                    <ignoreResultFailures>false</ignoreResultFailures>

                    <appendResultsTimestamp>true</appendResultsTimestamp>

                    <resultsFileFormat>csv</resultsFileFormat>

                    <generateReports>true</generateReports>

                    <reportConfig>

                    </reportConfig>

                    <!-- change protocol, server and port of tested API/web Application  -->

                    <propertiesUser>

                        <csvSource>${basedir}/src/test/resources</csvSource>

                        <!--<Server>${server}</Server>-->

                        <zap.host>${zap.server}</zap.host>

                        <environment>${Environment}</environment>

                        <!-- <region>${Region}</region> -->

                        <product>${Product}</product>

                        <!--<testcasename>${TestCaseName}</testcasename>-->

                        <targetResults>${basedir}/target/jmeter/results</targetResults>

                        <!--  <Port>${port}</Port> -->

                        <zap.port>${zap.port}</zap.port>

                    </propertiesUser>

                    <propertiesJMeter>

                        <log_level.jmeter>DEBUG</log_level.jmeter>

                        <jmeter.save.saveservice.response_data>true</jmeter.save.saveservice.response_data>

                        <jmeter.save.saveservice.url>true</jmeter.save.saveservice.url>

                    </propertiesJMeter>

                </configuration>    

               

            </plugin>

        </plugins>

    </build>

</project>
1

There are 1 answers

0
Dmitri T On
  1. Refer to your shell documentation, it looks like your shell doesn't allow dots in parameters names, the dots either need to be escaped or surrounded with quotation marks.

  2. Also consider ramping up your JMeter Maven Plugin version to the latest one, as of now it's 3.8.0, it will download latest JMeter and according to JMeter Best Practices you should always be using the latest version of JMeter.

  3. I don't think JMeter Maven Plugin respects dependencies block, you should rather go for special syntax to manipulate JMeter Classpath

More information: How to Use the JMeter Maven Plugin