Running Tests with mvn with -Dtags="critical" - no tests running

I’m running tests from project directory with this command:

mvn clean verify -Dtags=“critical”

But the tests are not running.

@Test
@WithTagValuesOf({ “critical” })

@Aleksei did you have such problem?

ignore previrous. was wrong. i do config what to run inside XML file.

when you execute your line it should be configured in POM default XML to start! or you should add what file to execute.

e.g.

mvn clean test -DsuiteXmlFile=src/test/java/recources/android_xxxxx.xml

share your pom.xml to see the problem. maybe another case.

also i am filtering tests inside “android_xxxxx.xml” e.g. by group annotation.

Here is my pom.xml

4.0.0 com.projectName project-mobile-ios 0.0.1-SNAPSHOT Project iOS Automation
<properties>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<serenity.version>1.2.5-rc.1</serenity.version>
	<webdriver.driver>appium</webdriver.driver>
</properties>

<dependencies>
	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>serenity-core</artifactId>
		<version>${serenity.version}</version>
	</dependency>
	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>serenity-junit</artifactId>
		<version>${serenity.version}</version>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>junit</groupId>
		<artifactId>junit</artifactId>
		<version>4.12</version>
	</dependency>
	<dependency>
		<groupId>org.assertj</groupId>
		<artifactId>assertj-core</artifactId>
		<version>3.6.1</version>
	</dependency>
	<dependency>
		<groupId>io.appium</groupId>
		<artifactId>java-client</artifactId>
		<version>5.0.0-BETA6</version>
	</dependency>
	<dependency>
		<groupId>com.google.code.gson</groupId>
		<artifactId>gson</artifactId>
		<version>2.8.0</version>
	</dependency>
	<dependency>
		<groupId>org.slf4j</groupId>
		<artifactId>slf4j-simple</artifactId>
		<version>1.7.21</version>
	</dependency>
	<dependency>
		<groupId>net.sourceforge.tess4j</groupId>
		<artifactId>tess4j</artifactId>
		<version>3.2.1</version>
		<exclusions>
			<exclusion>
				<groupId>ch.qos.logback</groupId>
				<artifactId>logback-classic</artifactId>
			</exclusion>
			<exclusion>
				<groupId>log4j</groupId>
				<artifactId>log4j</artifactId>
			</exclusion>
		</exclusions>
	</dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-support</artifactId>
        <version>3.0.1</version>
    </dependency>
</dependencies>
<build>
	<plugins>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-surefire-plugin</artifactId>
			<version>2.19.1</version>
			<configuration>
				<runOrder>alphabetical</runOrder>
				<argLine>-Xmx1024m</argLine>
				<systemPropertyVariables>
					<webdriver.driver>${webdriver.driver}</webdriver.driver>
				</systemPropertyVariables>
				<includes>
					<include>**/*Test.java</include>
				</includes>
			</configuration>
		</plugin>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-compiler-plugin</artifactId>
			<version>3.6.1</version>
			<configuration>
				<source>1.8</source>
				<target>1.8</target>
			</configuration>
		</plugin>
		<plugin>
			<groupId>net.serenity-bdd.maven.plugins</groupId>
			<artifactId>serenity-maven-plugin</artifactId>
			<version>${serenity.version}</version>
			<executions>
				<execution>
					<id>serenity-reports</id>
					<phase>post-integration-test</phase>
					<goals>
						<goal>aggregate</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
	</plugins>
</build>

i am using file injection:

                    <configuration>
                        <suiteXmlFiles>
                            <!-- Suite file injection parameter from command line -->
                            <suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
                        </suiteXmlFiles>
                    </configuration>

and as i said with testNG selecting with any tag needed. But i prefer to have very strict order.

inside testNG xml:

<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
<suite name="BVT_iOS" time-out="600000"> <!-- 1000x60x10 = 10min-->
    <listeners>
        <listener class-name="com.xxxx.base.RetryListener" />
        <listener class-name="com.xxxx.base.TestListener" />
    </listeners>
    <parameter name="runDestination" value="Local"/>
    <parameter name="devicePlatform" value="iOS"/>
    <parameter name="osVersion" value="10.3"/>
    <parameter name="appType" value="xxxxx"/>
    <parameter name="appiumServer2_Port" value="4726"/> <!-- 4725 Android_1, 4726 Android_2, 4727 iOS-->
    <parameter name="generateReport" value="true"/>

    <!--
    <parameter name="devicePlatform" value="android"/>
    <parameter name="devicePlatform" value="android fullReset/>


    <parameter name="runDestination" value="genymotion"/>
    <parameter name="runDestination" value="Local"/>

    <parameter name="deviceID" value="192.168.56.101:5555"/>

    <parameter name="deviceName" value="Nexus4"/>
    <parameter name="deviceName" value="phone_Nexus6_5.1.0_1440x2560"/>
    <parameter name="deviceName" value="LGH8155e9892e6"/> = LG G4

    <parameter name="osVersion" value="8.1"/>

    -->
    <test name="0 prepare phone, account and client" preserve-order="true">
        <parameter name="devicePlatform" value="iOS fullReset"/>
        <parameter name="deviceName" value="iPhone 6s"/> <!-- iPad Air  iPhone 6s -->
        <classes>
            <class name="com.xxxxx.tests.ios.xxxxxxx">
                <methods>
                    <include name="test_1"></include>
                </methods>
            </class>
            <class name="com.xxxx.tests.ios.xxxxx">
                <methods>
                    <include name="test_2"></include>
                </methods>
            </class>
        </classes>
    </test>
    <test name="execute_tests_with_client_reset" preserve-order="true">
        <parameter name="devicePlatform" value="iOS fastReset"/> <!-- fastReset -->
        <parameter name="deviceName" value="iPhone 6s"/>
        <classes>
            <class name="com.xxxx.tests.ios.xxxxxx">
                <methods>
                    <include name="test_1"></include>
                    <include name="test_2"></include>
                </methods>
            </class>
            ......
        </classes>
    </test>

    <test name="execute_tests_with_no_client_reset" preserve-order="true">
        <parameter name="devicePlatform" value="iOS"/>
        <parameter name="deviceName" value="iPhone 6s"/>
        <classes>
            <class name="com.xxxx.tests.ios.xxxx">
                <methods>
                    <include name="xxxx"></include>
                    <include name="xxxx"></include>
                </methods>
            </class>
        </classes>
    </test>
</suite>

We’re using different approaches you’re using testNG, me JUnit :slight_smile:

The problem is that in previous projects, I could run tests by the needed tag, but while trying here, even with the same pom.xml versions, no result. :frowning:

But thanks a lot @Aleksei for your suggestions :wink:

move to testNG - it is 100 times more convenient and more powerful. JUnit mostly for unit tests where flexibility not important.

@Aleksei, I’ve solved the problem. :slight_smile:

Test classes was named ex. “SignInTests”
@WithTagValuesOf({ “SignInTests” })

I renamed test classes into “SignInTest” - and it’s working. :slight_smile:

@sivanov wonderful. maybe ‘critical’ some reserved word

No it was the problem of the naming of test class :slight_smile: