在Maven中进行测试

时间:2016-09-14 21:59:55

标签: java eclipse maven appium

我是Maven的新手,并尝试使用相同的方法执行Appium测试用例。当我执行mvn test命令时,测试不会被执行。请在下面找到更多详细信息。

这是Java代码:

package Test;

import java.net.MalformedURLException;

import java.net.URL;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.remote.DesiredCapabilities;

import io.appium.java_client.android.AndroidDriver;

import io.appium.java_client.remote.MobileCapabilityType;

import io.appium.java_client.remote.MobilePlatform;

/**

 * Unit test for simple App

 */

public class AppTest

{

public void test() throws MalformedURLException 

{

DesiredCapabilities cap=new DesiredCapabilities();

cap.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);

cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Android device");

cap.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome");

AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),cap);

driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS);

driver.get("http://www.google.com");

}

}

MVN测试输出:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Test 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/gowtham/Desktop/Projects/Test/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Test ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ Test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/gowtham/Desktop/Projects/Test/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ Test ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/gowtham/Desktop/Projects/Test/target/test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ Test ---
[INFO] Surefire report directory: /Users/gowtham/Desktop/Projects/Test/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running Test.AppTest
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.092 s
[INFO] Finished at: 2016-09-14T14:34:17-07:00
[INFO] Final Memory: 20M/252M
[INFO] ------------------------------------------------------------------------

POM

<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>Test</groupId>

      <artifactId>Tests</artifactId>

      <version>1.0-SNAPSHOT</version>

      <packaging>jar</packaging>

      <name>Test</name>

      <url>http://maven.apache.org</url>

      <properties>

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

      </properties>

      <dependencies>

      <dependency>

        <groupId>io.appium</groupId>

        <artifactId>java-client</artifactId>

        <version>4.1.2</version>

    </dependency>

    <dependency>

        <groupId>org.seleniumhq.selenium</groupId>

        <artifactId>selenium-java</artifactId>

        <version>2.53.1</version>

    </dependency>

        <dependency>

          <groupId>junit</groupId>

          <artifactId>junit</artifactId>

          <version>3.8.1</version>

          <scope>test</scope>

        </dependency>

     </dependencies>

    </project>

1 个答案:

答案 0 :(得分:0)

您的依赖项中有JUnit版本3。 JUnit 3不支持不扩展TestCase的测试,而您的测试则不支持。扩展TestCase,或将JUnit版本更改为4.11

JUnit 3和4之间的主要区别列在this answer