2015-11-13 106 views
0

我無法執行整個腳本。現在我的腳本運行了@BeforeTest註釋,未運行@Test@AfterTest無法在testng中運行腳本

public class LaunchApp { 

    WebDriver driver = null; 

    @BeforeTest 
    public void setup() throws InterruptedException{ 

     DesiredCapabilities capabilities = new DesiredCapabilities(); 
     capabilities.setCapability("appium-version", "1.4.13.1"); 
     capabilities.setCapability("platformName", "Android"); 
     capabilities.setCapability("platformVersion", "5.0.2"); 
     capabilities.setCapability("deviceName", "CC55EYG01397"); 
     capabilities.setCapability("app", "E:\\build_1026.apk"); 
     try { 
     driver = new RemoteWebDriver(
      new URL("http://127.0.0.1:4723/wd/hub"), capabilities); 
     } catch (MalformedURLException e) { 
     e.printStackTrace(); 
     } 

     driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS); 
    } 

    @Test 
    public void appiumExampleTest() throws Exception { 

     WebElement phNo = driver.findElement(By.id("editTextFirst")); 
     phNo.sendKeys("99999999"); 

     driver.findElement(By.id("textViewContinue")); 


    } 

    @AfterTest 
    public void tearDown() { 
     if (driver != null) { 
     driver.quit(); 
     } 
    } 
} 

即使我從testng.xml運行該腳本仍未完全運行。 讓我知道我錯了。

+0

歡迎來到Stack Overflow!我編輯了你的問題,讓用戶更清楚地理解它,從而幫助你。祝你好運! – bfontaine

+0

你怎麼知道測試沒有運行?注意如果測試沒有運行或失敗,'@ AfterTest'方法將不會運行。要小心,TestNG不是JUnit,'@ Before/AfterTest'不是'@ BeforeAfterMethod'。 – juherr

+0

我在junit中使用Before,Test和After註釋執行了上面的腳本。它完全執行。但是在testng面臨的問題。我認爲我的註釋是不正確的。 – user5408418

回答

0

請確保您使用TestNG庫中的@Test註釋。有機會@Test註釋可能指向JUnit庫。請檢查它,這可能會解決它。