2016-09-14 16 views
1

Mavenには新しく、同じものを使ってAppiumテストケースを実行しようとしています。 mvn testコマンドを実行すると、テストは実行されません。詳細は以下をご覧ください。Mavenでのテスト実行

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> 
+0

Appiumについてはわかりませんが、テストメソッドに@Testを注釈付けしようとしましたか?ここでいくつかの例が見つかりましたhttps://github.com/appium/sample-code/blob/master/sample-code/examples/java/junit/src/test/java/com/saucelabs/appium/SimpleTest.javaそれらの注釈は、おそらくそれを試してみてください。 – Shadov

+0

はい、@Testアノテーションで試しましたが、運はありませんでした。 – gowthamjs23

答えて

0

あなたが依存関係にJUnitのバージョン3を持っている

は、ここでのJavaコードです。 JUnit 3は、TestCaseを拡張しないテストはサポートしていません。 TestCaseを拡張するか、JUnitのバージョンを4.11に変更してください。

JUnit 3と4の主な違いは、this answerです。

+0

extend TestCaseを使用して解決される問題。ありがとうございました! – gowthamjs23

関連する問題