Reputation: 556
My JDK is 1.8
version, Surefire is 2.22.2
, Maven is 3.6.3
. I am using junit and spring annotations.
When I try to run my tests with mavn test
command, I get no errores, I get success build and no cases run.
Running testCases.TestLogin Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@7bb11784 Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.808 sec
When I run the class using IntellIJ UI runner, the cases are run correctly. My class name starts with Test*
. Here is my test code.
package testCases; import appium.AppiumController; import org.junit.*; import org.springframework.context.annotation.Description; import screens.HomeScreen; import screens.LoginScreen; public class TestLogin extends AppiumController { protected static LoginScreen loginScreen; protected static HomeScreen homeScreen; @BeforeClass public static void setUp() throws Exception { startAppium(); loginScreen = new LoginScreen(driver, wait); homeScreen = new HomeScreen(driver, wait); } @After public void afterEach() { loginScreen.appReset(); } @Test @Description("Verify user can login with valid credentials") public void validLoginTest() throws Exception { loginScreen.login("admin", "admin"); Assert.assertTrue("Home screen is not visible\n", homeScreen.isHomeScreenVisible()); } @Test @Description("Verify user can not login with invalid credentials") public void invalidLoginTest() throws Exception { loginScreen.login("admin1", "admin1"); Assert.assertFalse("Home screen is visible\n", homeScreen.isHomeScreenVisible()); } @AfterClass public static void tearDown() throws Exception { stopAppium(); }
What is the problem and how can I run the test cases using command line?
Upvotes: 0
Views: 482
Reputation: 4349
You may be having both TestNg and Junit dependencies in the POM.xml
As per documentation of maven-surefire-plugin plugin for TestNg .You may want to run two providers, e.g. surefire-junit47 and surefire-testng, and avoid running JUnit tests within surefire-testng provider by setting property junit=false.
Documentation Ref - Section 'Running TestNG and JUnit Tests'
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<properties>
<property>
<name>junit</name>
<value>false</value>
</property>
</properties>
<threadCount>1</threadCount>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>3.0.0-M5</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>3.0.0-M5</version>
</dependency>
</dependencies>
</plugin>
Upvotes: 1