2016-11-16 21 views
0

我使用TestNG + Selenium + Appium。 我現在的問題是: 如果1st @Test失敗,所有的休息都會自動失敗,執行將會停止。所有測試在同一類別的第一次@Test失敗後自動失敗

我試圖使用@BecoreClass的設置,而不是在@TEST設置仍然失敗後的第一次失敗的一切。

我以爲它跳過所有測試的其餘部分,因爲它沒有以正確的方式完成該過程(退出應用程序),這就是爲什麼我添加@Aftermethod與driver.quit它會執行它之後失敗的方法。 但仍然在第一次失敗後,它會自動失敗所有的測試。

我需要有多個@Test與測試方法,這將是單獨的單獨配置。如果第一個失敗,它將繼續執行@Test的其餘部分(即使它們來自同一個類),之後會給我一個結果。

package foundation; 


import com.pageobjects.HeaderMenu; 
import config.AppConfiguration; 
import config.LogIn; 
import config.DesiredCapabilitiesSetup; 
import io.appium.java_client.android.AndroidDriver; 
import io.appium.java_client.android.AndroidElement; 
import io.appium.java_client.pagefactory.AppiumFieldDecorator; 
import org.openqa.selenium.support.PageFactory; 
import org.testng.annotations.*; 
import org.testng.asserts.SoftAssert; 


import java.io.IOException; 


public class AppiumTestTest { 
    private AndroidDriver<AndroidElement> driver; 

    private AOWebClient aoWeb; 

    @SuppressWarnings("unused") 
    public AppiumTestTest(AndroidDriver<AndroidElement> driver, AOWebClient aoWeb) { 
     this.driver = driver; 
     this.aoWeb = aoWeb; 
     PageFactory.initElements(new AppiumFieldDecorator(driver), this); 
    } 

    @SuppressWarnings("unused") 
    public AppiumTestTest() { 
    } 

    private SoftAssert softAssert = new SoftAssert(); 
/* 
    @BeforeClass 
    public void setUp() throws Exception { 
    } 
*/ 



    @Test 
    public void checkInTest() throws Exception { 

     driver = DesiredCapabilitiesSetup.startAppiumServer(
       AppConfiguration.newBuilder() 
         .setTimeSelection(false) 
         .setBirthday(true) 
         .build()); 
     AOWebClient aoWebClient = DesiredCapabilitiesSetup.getAOWeb(); 
     LogIn logIn = new LogIn(driver, aoWebClient); 
     logIn.logIn(); 
    } 




    @Test 
    public void timeSelectionTest() throws Exception { 

     driver = DesiredCapabilitiesSetup.startAppiumServer(
       AppConfiguration.newBuilder() 
         .setTimeSelection(true) 
         .setBirthday(true) 
         .build()); 
     AOWebClient aoWebClient = DesiredCapabilitiesSetup.getAOWeb(); 
     LogIn logIn = new LogIn(driver, aoWebClient); 
     logIn.logIn(); 
    } 
    @AfterMethod 
    public void afterM(){ 
     driver.close(); 
     driver.quit(); 
    } 


} 

我期望的能力是:

package config; 

import com.pageobjects.LaunchProgress; 
import com.sun.javafx.tools.ant.DeployFXTask; 
import io.appium.java_client.android.AndroidDriver; 
import io.appium.java_client.android.AndroidElement; 
import io.appium.java_client.remote.AndroidMobileCapabilityType; 
import io.appium.java_client.remote.MobileCapabilityType; 
import io.appium.java_client.remote.MobilePlatform; 
import org.apache.commons.codec.binary.Base64; 
import org.apache.commons.io.FileUtils; 
import org.json.simple.JSONObject; 
import org.openqa.selenium.remote.DesiredCapabilities; 
import org.testng.annotations.BeforeClass; 

import java.io.File; 
import java.io.IOException; 
import java.net.URL; 
import java.util.concurrent.TimeUnit; 


public class DesiredCapabilitiesSetup { 


    //Name of Android Device 
    //public static String deviceName = "TestDevice"; 

    // Emulator 
    //public static String deviceName = "One"; 

    //Path of App folder 
    // public static String appLink = "/Users/af185125/FoundationApp/"; 


    //The name of Android application with format. (.apk). 
    //public static String appName = "app331.apk"; 


    private static final String KEY_USE_TIME_SELECTION = "useTimeSelection"; 
    private static final String KEY_DISABLE_BIRTHDAY = "disableBirthday"; 

    @BeforeClass 
    public static AndroidDriver<AndroidElement> startAppiumServer(AppConfiguration appConfiguration) throws IOException { 
// Taking App/Device/Link path from *txt file located in the project // 
     /* 
     String appLink = FileUtils.readFileToString(new File("appConfigurations/appLink.txt")); 
     String deviceName = FileUtils.readFileToString(new File("appConfigurations/deviceName.txt")); 
     String appName = FileUtils.readFileToString(new File("appConfigurations/appName.txt")); 
     */ 


     String appLink = FileUtils.readFileToString(new File("appConfigurations/appLink.txt")); 
     String deviceName = FileUtils.readFileToString(new File("appConfigurations/deviceName.txt")); 
     String appName = FileUtils.readFileToString(new File("appConfigurations/appName.txt")); 

     DesiredCapabilities cap = new DesiredCapabilities(); 
     cap.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID); 
     cap.setCapability(MobileCapabilityType.DEVICE_NAME, deviceName); 
     cap.setCapability(MobileCapabilityType.VERSION, "6.0"); 
     cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "4000"); 

     String configurationString = getConfigurationString(appConfiguration); 
     cap.setCapability(AndroidMobileCapabilityType.OPTIONAL_INTENT_ARGUMENTS,"--es appium_config \"" + configurationString + "\""); 

     //cap.setCapability("avd","nexus"); 
     File appSource = new File(appLink); 
     File app = new File(appSource, appName); 
     cap.setCapability(MobileCapabilityType.APP, app.getAbsolutePath()); 



     AndroidDriver<AndroidElement> driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap); 
     driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS); 




     LaunchProgress launch = new LaunchProgress(driver); 
     launch.waitForLaunchScreenToLoad(); 


     return driver; 

    } 

    @SuppressWarnings("unchecked") 
    private static String getConfigurationString(AppConfiguration appConfiguration) { 
     JSONObject configuration = new JSONObject(); 
     configuration.put(KEY_USE_TIME_SELECTION, appConfiguration.timeSelection); 
     configuration.put(KEY_DISABLE_BIRTHDAY, appConfiguration.birthday); 
     return configuration.toJSONString(); 
    } 

} 

堆棧跟蹤:

objc[20683]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined. 
Connected to the target VM, address: '127.0.0.1:58385', transport: 'socket' 
[TestNG] Running: 
    /Users/af185125/Library/Caches/IdeaIC2016.2/temp-testng-customsuite.xml 

org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information) 
Command duration or timeout: 80.28 seconds 
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html 
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09' 
System info: host: 'WUSAF185125-G3D', ip: '153.86.242.30', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_91' 
Driver info: io.appium.java_client.android.AndroidDriver 
Capabilities [{app=/Users/af185125/android-ui-test/currentApp/appiumT.apk, appPackage=com.ao.demo.beta, networkConnectionEnabled=true, warnings={}, appWaitPackage=com.ao.demo.beta, appWaitActivity=com.ao.core.ui.launch.LaunchActivity, databaseEnabled=false, deviceName=ad071603280ea0c18d, version=6.0, fullReset=true, platform=LINUX, deviceUDID=ad071603280ea0c18d, appActivity=com.ao.core.ui.launch.LaunchActivity, desired={app=/Users/af185125/android-ui-test/currentApp/appiumT.apk, newCommandTimeout=4000, platformVersion=6.0, automationName=Appium, platformName=Android, deviceName=Automation, version=6.0, optionalIntentArguments=--es appium_config "{"useTimeSelection":false,"disableBirthday":true}", fullReset=true}, newCommandTimeout=4000, platformVersion=6.0.1, webStorageEnabled=false, locationContextEnabled=false, automationName=Appium, takesScreenshot=true, javascriptEnabled=true, platformName=Android, optionalIntentArguments=--es appium_config "{"useTimeSelection":false,"disableBirthday":true}"}] 
Session ID: 30270d0f-8594-4ead-b5b6-56dfeee37f44 
*** Element info: {Using=id, value=fasf.com} 

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) 
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678) 
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:51) 
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1) 
    at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1) 
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363) 
    at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:67) 
    at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1) 
    at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1) 
    at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:413) 
    at io.appium.java_client.DefaultGenericMobileDriver.findElementById(DefaultGenericMobileDriver.java:75) 
    at io.appium.java_client.AppiumDriver.findElementById(AppiumDriver.java:1) 
    at io.appium.java_client.android.AndroidDriver.findElementById(AndroidDriver.java:1) 
    at org.openqa.selenium.By$ById.findElement(By.java:218) 
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:355) 
    at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:63) 
    at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1) 
    at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1) 
    at foundation.AppiumTestTest.checkInTest(AppiumTestTest.java:61) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100) 
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:646) 
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:811) 
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1129) 
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129) 
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112) 
    at org.testng.TestRunner.privateRun(TestRunner.java:746) 
    at org.testng.TestRunner.run(TestRunner.java:600) 
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:366) 
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361) 
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319) 
    at org.testng.SuiteRunner.run(SuiteRunner.java:268) 
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) 
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) 
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1264) 
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1189) 
    at org.testng.TestNG.runSuites(TestNG.java:1104) 
    at org.testng.TestNG.run(TestNG.java:1076) 
    at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72) 
    at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:124) 


org.openqa.selenium.WebDriverException: Method has not yet been implemented (WARNING: The server did not provide any stacktrace information) 
Command duration or timeout: 7 milliseconds 
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09' 
System info: host: 'WUSAF185125-G3D', ip: '153.86.242.30', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_91' 
Driver info: io.appium.java_client.android.AndroidDriver 
Capabilities [{app=/Users/af185125/android-ui-test/currentApp/appiumT.apk, appPackage=com.ao.demo.beta, networkConnectionEnabled=true, warnings={}, appWaitPackage=com.ao.demo.beta, appWaitActivity=com.ao.core.ui.launch.LaunchActivity, databaseEnabled=false, deviceName=ad071603280ea0c18d, version=6.0, fullReset=true, platform=LINUX, deviceUDID=ad071603280ea0c18d, appActivity=com.ao.core.ui.launch.LaunchActivity, desired={app=/Users/af185125/android-ui-test/currentApp/appiumT.apk, newCommandTimeout=4000, platformVersion=6.0, automationName=Appium, platformName=Android, deviceName=Automation, version=6.0, optionalIntentArguments=--es appium_config "{"useTimeSelection":false,"disableBirthday":true}", fullReset=true}, newCommandTimeout=4000, platformVersion=6.0.1, webStorageEnabled=false, locationContextEnabled=false, automationName=Appium, takesScreenshot=true, javascriptEnabled=true, platformName=Android, optionalIntentArguments=--es appium_config "{"useTimeSelection":false,"disableBirthday":true}"}] 
Session ID: 30270d0f-8594-4ead-b5b6-56dfeee37f44 

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) 
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678) 
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:51) 
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:268) 
    at org.openqa.selenium.remote.RemoteWebDriver.close(RemoteWebDriver.java:521) 
    at foundation.AppiumTestTest.afterM(AppiumTestTest.java:46) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100) 
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515) 
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:216) 
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:712) 
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:811) 
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1129) 
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129) 
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112) 
    at org.testng.TestRunner.privateRun(TestRunner.java:746) 
    at org.testng.TestRunner.run(TestRunner.java:600) 
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:366) 
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361) 
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319) 
    at org.testng.SuiteRunner.run(SuiteRunner.java:268) 
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) 
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) 
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1264) 
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1189) 
    at org.testng.TestNG.runSuites(TestNG.java:1104) 
    at org.testng.TestNG.run(TestNG.java:1076) 
    at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72) 
    at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:124) 


Test ignored. 
org.openqa.selenium.WebDriverException: Method has not yet been implemented (WARNING: The server did not provide any stacktrace information) 
Command duration or timeout: 5 milliseconds 
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09' 
System info: host: 'WUSAF185125-G3D', ip: '153.86.242.30', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_91' 
Driver info: io.appium.java_client.android.AndroidDriver 
Capabilities [{app=/Users/af185125/android-ui-test/currentApp/appiumT.apk, appPackage=com.ao.demo.beta, networkConnectionEnabled=true, warnings={}, appWaitPackage=com.ao.demo.beta, appWaitActivity=com.ao.core.ui.launch.LaunchActivity, databaseEnabled=false, deviceName=ad071603280ea0c18d, version=6.0, fullReset=true, platform=LINUX, deviceUDID=ad071603280ea0c18d, appActivity=com.ao.core.ui.launch.LaunchActivity, desired={app=/Users/af185125/android-ui-test/currentApp/appiumT.apk, newCommandTimeout=4000, platformVersion=6.0, automationName=Appium, platformName=Android, deviceName=Automation, version=6.0, optionalIntentArguments=--es appium_config "{"useTimeSelection":false,"disableBirthday":true}", fullReset=true}, newCommandTimeout=4000, platformVersion=6.0.1, webStorageEnabled=false, locationContextEnabled=false, automationName=Appium, takesScreenshot=true, javascriptEnabled=true, platformName=Android, optionalIntentArguments=--es appium_config "{"useTimeSelection":false,"disableBirthday":true}"}] 
Session ID: 30270d0f-8594-4ead-b5b6-56dfeee37f44 

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) 
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678) 
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:51) 
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:268) 
    at org.openqa.selenium.remote.RemoteWebDriver.close(RemoteWebDriver.java:521) 
    at foundation.AppiumTestTest.afterM(AppiumTestTest.java:46) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100) 
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515) 
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:216) 
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:712) 
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:811) 
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1129) 
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129) 
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112) 
    at org.testng.TestRunner.privateRun(TestRunner.java:746) 
    at org.testng.TestRunner.run(TestRunner.java:600) 
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:366) 
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361) 
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319) 
    at org.testng.SuiteRunner.run(SuiteRunner.java:268) 
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) 
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) 
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1264) 
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1189) 
    at org.testng.TestNG.runSuites(TestNG.java:1104) 
    at org.testng.TestNG.run(TestNG.java:1076) 
    at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72) 
    at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:124) 
+0

我試過用(alwaysRun = true) 沒有幫助。 – Anton

+0

您需要向我們展示完整的堆棧跟蹤,以便我們可以瞭解您的故障的性質。 –

+0

我認爲你的問題是,因爲你在after方法中使用了driver.quit,所以在執行第一個testcase之後,你的驅動程序不會再次初始化。嘗試在beforeclass中初始化驅動程序一次,並在事後或下課時退出該驅動程序。 – noor

回答

1

移動driver = DesiredCapabilitiesSetup.startAppiumServer...@BeforeMethod。此外,如果您想使用不同的驅動程序進行測試,則必須添加參數設置(例如,組@BeforeMethod,組@DataProvider@Facotry)。

+0

但是,如果我有兩個不同的@Test應該有不同的設置在同一類下? 基本上單個流程已針對2個類似的應用程序進行測試,但一些配置不同。 – Anton

+0

你的情況最簡單的是使用'組' - 用兩組標記你的測試,併爲每個組創建'@BeforeMethod'。 – RocketRaccoon

相關問題