在 maven testng selenium java 中禁用并行执行(使用 surefire 插件 - 它不会 运行 根据 testng.xml 中的顺序)
Disable parallel execution in maven testng selenium java (using the surefire plugin - it does not run according to the order in the testng.xml)
我正在开发一个 Maven TestNG Selenium Java 项目,并试图通过从我的 pom.xml 调用我的 testng.xml 来 运行 我的测试。
项目本身在它的非 Maven 版本中工作正常,但是当我 运行 它通过 pom.xml 文件时,它只是 运行s 所有并行测试,打开网站并且只是运行 将所有测试放在一起(我需要按顺序 运行 它们,因为它们相互依赖,而且 @BeforeSuite
和 @AfterSuite
方法工作得很好,问题是仅在执行 @Test
类型时)
我尝试遵循 Internet 上的几个指南和类似的项目示例,并根据它们删除和添加依赖项,但 none 似乎有效。
这是我目前的 pom.xml(到此为止一团糟):
<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>ZafulSelMaven4</groupId>
<artifactId>ZafulSelMaven4</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ZafulSelMaven4</name>
<url>http://maven.apache.org</url>
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.argument.target>${maven.compiler.target}</maven.compiler.argument.target>
<maven.compiler.argument.source>${maven.compiler.source}</maven.compiler.argument.source>
<appium-java-client.version>7.1.0</appium-java-client.version>
<spring-boot.version>2.1.6.RELEASE</spring-boot.version>
<slf4j.version>1.7.25</slf4j.version>
<logback.version>1.2.3</logback.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<suiteXmlFile>testng.xml</suiteXmlFile>
<java.version>1.8</java.version>
<!--Dependency Versions-->
<selenium.version>3.141.59</selenium.version>
<assertj-core.version>3.15.0</assertj-core.version>
<testng.version>7.1.0</testng.version>
<query.version>2.0.0-BETA3</query.version>
<!--Plugin Versions-->
<driver-binary-downloader-maven-plugin.version>1.0.18</driver-binary-downloader-maven-plugin.version>
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
<maven-failsafe-plugin.version>2.22.2</maven-failsafe-plugin.version>
<!--Configuration Properties-->
<overwrite.binaries>false</overwrite.binaries>
<read.timeout>30000</read.timeout>
<connection.timeout>40000</connection.timeout>
<retry.attempts>4</retry.attempts>
<browser>chrome</browser>
<threads>1</threads>
<remote>false</remote>
<headless>true</headless>
<seleniumGridURL/>
<platform/>
<browserVersion/>
<proxyEnabled>false</proxyEnabled>
<proxyHost/>
<proxyPort/>
<proxyUsername/>
<proxyPassword/>
</properties>
<dependencies>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>${appium-java-client.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>${selenium.version}</version><!--$NO-MVN-MAN-VER$-->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version><!--$NO-MVN-MAN-VER$-->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj-core.version}</version><!--$NO-MVN-MAN-VER$-->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.lazerycode.selenium</groupId>
<artifactId>query</artifactId>
<version>${query.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20170516</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>selenium-tests</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
<suitename>Test_Suite</suitename>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
<version>${maven-compiler-plugin.version}</version>
</plugin>
<plugin>
<groupId>com.lazerycode.selenium</groupId>
<artifactId>driver-binary-downloader-maven-plugin</artifactId>
<version>${driver-binary-downloader-maven-plugin.version}</version>
<configuration>
<rootStandaloneServerDirectory>${project.basedir}/src/test/resources/selenium_standalone_binaries</rootStandaloneServerDirectory>
<downloadedZipFileDirectory>${project.basedir}/src/test/resources/selenium_standalone_zips</downloadedZipFileDirectory>
<customRepositoryMap>${project.basedir}/src/test/resources/RepositoryMap.xml</customRepositoryMap>
<overwriteFilesThatExist>${overwrite.binaries}</overwriteFilesThatExist>
<onlyGetDriversForHostOperatingSystem>false</onlyGetDriversForHostOperatingSystem>
<fileDownloadRetryAttempts>${retry.attempts}</fileDownloadRetryAttempts>
<fileDownloadReadTimeout>${read.timeout}</fileDownloadReadTimeout>
<operatingSystems>
<windows>true</windows>
<linux>true</linux>
<mac>true</mac>
</operatingSystems>
</configuration>
<executions>
<execution>
<goals>
<goal>selenium</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<configuration>
<parallel>methods</parallel>
<threadCount>${threads}</threadCount>
<systemPropertyVariables>
<browser>${browser}</browser>
<screenshotDirectory>${project.build.directory}/screenshots</screenshotDirectory>
<remoteDriver>${remote}</remoteDriver>
<gridURL>${seleniumGridURL}</gridURL>
<desiredPlatform>${platform}</desiredPlatform>
<desiredBrowserVersion>${browserVersion}</desiredBrowserVersion>
<proxyEnabled>${proxyEnabled}</proxyEnabled>
<proxyHost>${proxyHost}</proxyHost>
<proxyPort>${proxyPort}</proxyPort>
<proxyUsername>${proxyUsername}</proxyUsername>
<proxyPassword>${proxyPassword}</proxyPassword>
<headless>${headless}</headless>
<!--Set properties passed in by the driver binary downloader-->
<webdriver.chrome.driver>${webdriver.chrome.driver}</webdriver.chrome.driver>
<webdriver.ie.driver>${webdriver.ie.driver}</webdriver.ie.driver>
<webdriver.opera.driver>${webdriver.opera.driver}</webdriver.opera.driver>
<webdriver.gecko.driver>${webdriver.gecko.driver}</webdriver.gecko.driver>
<webdriver.edge.driver>${webdriver.edge.driver}</webdriver.edge.driver>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<!--This goal makes the build fail if you have test failures-->
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
这是我 运行 我的 pom.xml 文件作为 maven 测试后的控制台:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ZafulSelMaven4 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ ZafulSelMaven4 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ ZafulSelMaven4 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ ZafulSelMaven4 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 37 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ ZafulSelMaven4 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- driver-binary-downloader-maven-plugin:1.0.18:selenium (default) @ ZafulSelMaven4 ---
[INFO]
[INFO] --------------------------------------------------------
[INFO] DOWNLOADING SELENIUM STAND-ALONE EXECUTABLE BINARIES...
[INFO] --------------------------------------------------------
[INFO]
[INFO] Repository map 'file:/C:/Users/hagit/workspace/ZafulSelMaven4/src/test/resources/RepositoryMap.xml' is valid
[INFO]
[INFO] Only get drivers for current Operating System: false
[INFO] Archives will be downloaded to 'C:\Users\hagit\workspace\ZafulSelMaven4\src\test\resources\selenium_standalone_zips'
[INFO] Standalone executable files will be extracted to 'C:\Users\hagit\workspace\ZafulSelMaven4\src\test\resources\selenium_standalone_binaries'
[INFO]
[INFO] Preparing to download Selenium Standalone Executable Binaries...
[INFO] Binary 'operadriver' exists: true
[INFO] Using existing 'operadriver 'binary.
[INFO] Binary 'operadriver' exists: true
[INFO] Using existing 'operadriver 'binary.
[INFO] Binary 'IEDriverServer.exe' exists: true
[INFO] Using existing 'IEDriverServer.exe 'binary.
[INFO] Binary 'msedgedriver' exists: true
[INFO] Using existing 'msedgedriver 'binary.
[INFO] Binary 'chromedriver' exists: true
[INFO] Using existing 'chromedriver 'binary.
[INFO] Binary 'operadriver.exe' exists: true
[INFO] Using existing 'operadriver.exe 'binary.
[INFO] Binary 'chromedriver' exists: true
[INFO] Using existing 'chromedriver 'binary.
[INFO] Binary 'geckodriver.exe' exists: true
[INFO] Using existing 'geckodriver.exe 'binary.
[INFO] Binary 'msedgedriver.exe' exists: true
[INFO] Using existing 'msedgedriver.exe 'binary.
[INFO] Binary 'chromedriver.exe' exists: true
[INFO] Using existing 'chromedriver.exe 'binary.
[INFO] Binary 'geckodriver' exists: true
[INFO] Using existing 'geckodriver 'binary.
[INFO] Binary 'geckodriver' exists: true
[INFO] Using existing 'geckodriver 'binary.
[INFO] Setting maven property - ${webdriver.ie.driver} = C:\Users\hagit\workspace\ZafulSelMaven4\src\test\resources\selenium_standalone_binaries\windows\internetexplorerbit\IEDriverServer.exe
[INFO] Setting maven property - ${webdriver.opera.driver} = C:\Users\hagit\workspace\ZafulSelMaven4\src\test\resources\selenium_standalone_binaries\windows\operachromiumbit\operadriver.exe
[INFO] Setting maven property - ${webdriver.gecko.driver} = C:\Users\hagit\workspace\ZafulSelMaven4\src\test\resources\selenium_standalone_binaries\windows\marionettebit\geckodriver.exe
[INFO] Setting maven property - ${webdriver.edge.driver} = C:\Users\hagit\workspace\ZafulSelMaven4\src\test\resources\selenium_standalone_binaries\windows\edgebit\msedgedriver.exe
[INFO] Setting maven property - ${webdriver.chrome.driver} = C:\Users\hagit\workspace\ZafulSelMaven4\src\test\resources\selenium_standalone_binaries\windows\googlechromebit\chromedriver.exe
[INFO]
[INFO] --------------------------------------------------------
[INFO] SELENIUM STAND-ALONE EXECUTABLE DOWNLOADS COMPLETE
[INFO] --------------------------------------------------------
[INFO]
[INFO]
[INFO] --- maven-surefire-plugin:3.0.0-M3:test (default-test) @ ZafulSelMaven4 ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
Zaful_Maven_Project
Jul 13, 2020 3:12:56 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
15:12:57.230 [main] DEBUG io.github.bonigarcia.wdm.Preferences - Preference chrome=83 (valid until 2020-07-13 16:07:04)
15:12:57.241 [main] DEBUG io.github.bonigarcia.wdm.Preferences - Preference chrome83=83.0.4103.39 (valid until 2020-07-13 16:07:04)
15:12:57.242 [main] INFO io.github.bonigarcia.wdm.WebDriverManager - Using chromedriver 83.0.4103.39 (since Google Chrome 83 is installed in your machine)
15:12:57.272 [main] DEBUG io.github.bonigarcia.wdm.WebDriverManager - Driver chromedriver 83.0.4103.39 found in cache
15:12:57.273 [main] INFO io.github.bonigarcia.wdm.WebDriverManager - Exporting webdriver.chrome.driver as C:\Users\hagit\.m2\repository\webdriver\chromedriver\win32.0.4103.39\chromedriver.exe
Local Operating System: WINDOWS 10
Local Architecture: amd64
Selected Browser: chrome
Connecting to Selenium Grid: false
Starting ChromeDriver 83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103@{#416}) on port 37771
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Jul 13, 2020 3:13:01 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Entered Test 1: Open Zaful
Written screenshot to target/screenshots94642387816_Logo_Exsists.png
Entered Test 1: Open Zaful
Written screenshot to target/screenshots94642392370_Logo_Exsists.png
Entered Test 2: Blue Bikini
Written screenshot to target/screenshots94642393496_Blue_Bikini_List.png
Entered Test 3: Black Bikini Like
Passed
Entered Test 1: Open Zaful
Written screenshot to target/screenshots94642396467_Logo_Exsists.png
Entered Test 2: Blue Bikini
Written screenshot to target/screenshots94642397495_Blue_Bikini_List.png
Entered Test 3: Black Bikini Like
Passed
Entered Test 3: Refresh no Like
Passed
Entered Test 1: Open Zaful
Written screenshot to target/screenshots94642403344_Logo_Exsists.png
Entered Test 2: Blue Bikini
Written screenshot to target/screenshots94642404359_Blue_Bikini_List.png
Entered Test 3: Black Bikini Like
Passed
Entered Test 3: Refresh no Like
Passed
Entered Test 1: Open Zaful
Written screenshot to target/screenshots94642409144_Logo_Exsists.png
Entered Test 2: Blue Bikini
Written screenshot to target/screenshots94642410471_Blue_Bikini_List.png
TestJASON.json2020_07_13
[ERROR] Tests run: 14, Failures: 9, Errors: 0, Skipped: 0, Time elapsed: 36.35 s <<< FAILURE! - in TestSuite
[ERROR] Logo_Exsists(testcases.OpenZafulTest) Time elapsed: 8.149 s <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Coordinates
at testcases.OpenZafulTest.Logo_Exsists(OpenZafulTest.java:53)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.Coordinates
at testcases.OpenZafulTest.Logo_Exsists(OpenZafulTest.java:53)
[ERROR] Logo_Exsists(testcases.BlueBikiniListTest) Time elapsed: 3.539 s <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Coordinates
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.Coordinates
[ERROR] Blue_Bikini_List(testcases.BlueBikiniListTest) Time elapsed: 0.691 s <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Coordinates
at testcases.BlueBikiniListTest.Blue_Bikini_List(BlueBikiniListTest.java:39)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.Coordinates
at testcases.BlueBikiniListTest.Blue_Bikini_List(BlueBikiniListTest.java:39)
[ERROR] Logo_Exsists(testcases.LikeBlackBikiniTest) Time elapsed: 3.05 s <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Coordinates
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.Coordinates
[ERROR] Blue_Bikini_List(testcases.LikeBlackBikiniTest) Time elapsed: 1.169 s <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Coordinates
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.Coordinates
[ERROR] Logo_Exsists(testcases.NoLikesAfterRefreshTest) Time elapsed: 2.994 s <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Coordinates
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.Coordinates
[ERROR] Blue_Bikini_List(testcases.NoLikesAfterRefreshTest) Time elapsed: 0.741 s <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Coordinates
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.Coordinates
[ERROR] Logo_Exsists(testcases.JsonWriterTest) Time elapsed: 3.376 s <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Coordinates
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.Coordinates
[ERROR] Blue_Bikini_List(testcases.JsonWriterTest) Time elapsed: 1.097 s <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Coordinates
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.Coordinates
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] BlueBikiniListTest.Blue_Bikini_List:39 » NoClassDefFound org/openqa/selenium/i...
[ERROR] BlueBikiniListTest>OpenZafulTest.Logo_Exsists:53 » NoClassDefFound org/openqa/...
[ERROR] JsonWriterTest>BlueBikiniListTest.Blue_Bikini_List:39 » NoClassDefFound org/op...
[ERROR] JsonWriterTest>OpenZafulTest.Logo_Exsists:53 » NoClassDefFound org/openqa/sele...
[ERROR] LikeBlackBikiniTest>BlueBikiniListTest.Blue_Bikini_List:39 » NoClassDefFound o...
[ERROR] LikeBlackBikiniTest>OpenZafulTest.Logo_Exsists:53 » NoClassDefFound org/openqa...
[ERROR] NoLikesAfterRefreshTest>BlueBikiniListTest.Blue_Bikini_List:39 » NoClassDefFound
[ERROR] NoLikesAfterRefreshTest>OpenZafulTest.Logo_Exsists:53 » NoClassDefFound org/op...
[ERROR] OpenZafulTest.Logo_Exsists:53 » NoClassDefFound org/openqa/selenium/interactio...
[INFO]
[ERROR] Tests run: 14, Failures: 9, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 43.867 s
[INFO] Finished at: 2020-07-13T15:13:32+03:00
[INFO] Final Memory: 25M/268M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test) on project ZafulSelMaven4: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Users\hagit\workspace\ZafulSelMaven4\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
这是 testng.xml :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Test_Suite" parallel="none" thread-count="1">
<test name="Test">
<classes>
<class name="testcases.OpenZafulTest"/>
<class name="testcases.BlueBikiniListTest"/>
<class name="testcases.LikeBlackBikiniTest"/>
<class name="testcases.NoLikesAfterRefreshTest"/>
<class name="testcases.JsonWriterTest"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
我想 运行 按照他们的顺序进行测试(class 按 class),所以如果有人知道该怎么做,那将对我有很大帮助。
这就是 TestNG 的行为方式。测试不会按 testng.xml 中列出的顺序执行。您应该按要求的顺序将测试的优先级分配给 运行。如果测试相互依赖,则使用依赖。在此处查看文档。
我正在开发一个 Maven TestNG Selenium Java 项目,并试图通过从我的 pom.xml 调用我的 testng.xml 来 运行 我的测试。
项目本身在它的非 Maven 版本中工作正常,但是当我 运行 它通过 pom.xml 文件时,它只是 运行s 所有并行测试,打开网站并且只是运行 将所有测试放在一起(我需要按顺序 运行 它们,因为它们相互依赖,而且 @BeforeSuite
和 @AfterSuite
方法工作得很好,问题是仅在执行 @Test
类型时)
我尝试遵循 Internet 上的几个指南和类似的项目示例,并根据它们删除和添加依赖项,但 none 似乎有效。
这是我目前的 pom.xml(到此为止一团糟):
<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>ZafulSelMaven4</groupId>
<artifactId>ZafulSelMaven4</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ZafulSelMaven4</name>
<url>http://maven.apache.org</url>
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.argument.target>${maven.compiler.target}</maven.compiler.argument.target>
<maven.compiler.argument.source>${maven.compiler.source}</maven.compiler.argument.source>
<appium-java-client.version>7.1.0</appium-java-client.version>
<spring-boot.version>2.1.6.RELEASE</spring-boot.version>
<slf4j.version>1.7.25</slf4j.version>
<logback.version>1.2.3</logback.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<suiteXmlFile>testng.xml</suiteXmlFile>
<java.version>1.8</java.version>
<!--Dependency Versions-->
<selenium.version>3.141.59</selenium.version>
<assertj-core.version>3.15.0</assertj-core.version>
<testng.version>7.1.0</testng.version>
<query.version>2.0.0-BETA3</query.version>
<!--Plugin Versions-->
<driver-binary-downloader-maven-plugin.version>1.0.18</driver-binary-downloader-maven-plugin.version>
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
<maven-failsafe-plugin.version>2.22.2</maven-failsafe-plugin.version>
<!--Configuration Properties-->
<overwrite.binaries>false</overwrite.binaries>
<read.timeout>30000</read.timeout>
<connection.timeout>40000</connection.timeout>
<retry.attempts>4</retry.attempts>
<browser>chrome</browser>
<threads>1</threads>
<remote>false</remote>
<headless>true</headless>
<seleniumGridURL/>
<platform/>
<browserVersion/>
<proxyEnabled>false</proxyEnabled>
<proxyHost/>
<proxyPort/>
<proxyUsername/>
<proxyPassword/>
</properties>
<dependencies>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>${appium-java-client.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>${selenium.version}</version><!--$NO-MVN-MAN-VER$-->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version><!--$NO-MVN-MAN-VER$-->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj-core.version}</version><!--$NO-MVN-MAN-VER$-->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.lazerycode.selenium</groupId>
<artifactId>query</artifactId>
<version>${query.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20170516</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>selenium-tests</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
<suitename>Test_Suite</suitename>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
<version>${maven-compiler-plugin.version}</version>
</plugin>
<plugin>
<groupId>com.lazerycode.selenium</groupId>
<artifactId>driver-binary-downloader-maven-plugin</artifactId>
<version>${driver-binary-downloader-maven-plugin.version}</version>
<configuration>
<rootStandaloneServerDirectory>${project.basedir}/src/test/resources/selenium_standalone_binaries</rootStandaloneServerDirectory>
<downloadedZipFileDirectory>${project.basedir}/src/test/resources/selenium_standalone_zips</downloadedZipFileDirectory>
<customRepositoryMap>${project.basedir}/src/test/resources/RepositoryMap.xml</customRepositoryMap>
<overwriteFilesThatExist>${overwrite.binaries}</overwriteFilesThatExist>
<onlyGetDriversForHostOperatingSystem>false</onlyGetDriversForHostOperatingSystem>
<fileDownloadRetryAttempts>${retry.attempts}</fileDownloadRetryAttempts>
<fileDownloadReadTimeout>${read.timeout}</fileDownloadReadTimeout>
<operatingSystems>
<windows>true</windows>
<linux>true</linux>
<mac>true</mac>
</operatingSystems>
</configuration>
<executions>
<execution>
<goals>
<goal>selenium</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<configuration>
<parallel>methods</parallel>
<threadCount>${threads}</threadCount>
<systemPropertyVariables>
<browser>${browser}</browser>
<screenshotDirectory>${project.build.directory}/screenshots</screenshotDirectory>
<remoteDriver>${remote}</remoteDriver>
<gridURL>${seleniumGridURL}</gridURL>
<desiredPlatform>${platform}</desiredPlatform>
<desiredBrowserVersion>${browserVersion}</desiredBrowserVersion>
<proxyEnabled>${proxyEnabled}</proxyEnabled>
<proxyHost>${proxyHost}</proxyHost>
<proxyPort>${proxyPort}</proxyPort>
<proxyUsername>${proxyUsername}</proxyUsername>
<proxyPassword>${proxyPassword}</proxyPassword>
<headless>${headless}</headless>
<!--Set properties passed in by the driver binary downloader-->
<webdriver.chrome.driver>${webdriver.chrome.driver}</webdriver.chrome.driver>
<webdriver.ie.driver>${webdriver.ie.driver}</webdriver.ie.driver>
<webdriver.opera.driver>${webdriver.opera.driver}</webdriver.opera.driver>
<webdriver.gecko.driver>${webdriver.gecko.driver}</webdriver.gecko.driver>
<webdriver.edge.driver>${webdriver.edge.driver}</webdriver.edge.driver>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<!--This goal makes the build fail if you have test failures-->
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
这是我 运行 我的 pom.xml 文件作为 maven 测试后的控制台:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ZafulSelMaven4 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ ZafulSelMaven4 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ ZafulSelMaven4 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ ZafulSelMaven4 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 37 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ ZafulSelMaven4 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- driver-binary-downloader-maven-plugin:1.0.18:selenium (default) @ ZafulSelMaven4 ---
[INFO]
[INFO] --------------------------------------------------------
[INFO] DOWNLOADING SELENIUM STAND-ALONE EXECUTABLE BINARIES...
[INFO] --------------------------------------------------------
[INFO]
[INFO] Repository map 'file:/C:/Users/hagit/workspace/ZafulSelMaven4/src/test/resources/RepositoryMap.xml' is valid
[INFO]
[INFO] Only get drivers for current Operating System: false
[INFO] Archives will be downloaded to 'C:\Users\hagit\workspace\ZafulSelMaven4\src\test\resources\selenium_standalone_zips'
[INFO] Standalone executable files will be extracted to 'C:\Users\hagit\workspace\ZafulSelMaven4\src\test\resources\selenium_standalone_binaries'
[INFO]
[INFO] Preparing to download Selenium Standalone Executable Binaries...
[INFO] Binary 'operadriver' exists: true
[INFO] Using existing 'operadriver 'binary.
[INFO] Binary 'operadriver' exists: true
[INFO] Using existing 'operadriver 'binary.
[INFO] Binary 'IEDriverServer.exe' exists: true
[INFO] Using existing 'IEDriverServer.exe 'binary.
[INFO] Binary 'msedgedriver' exists: true
[INFO] Using existing 'msedgedriver 'binary.
[INFO] Binary 'chromedriver' exists: true
[INFO] Using existing 'chromedriver 'binary.
[INFO] Binary 'operadriver.exe' exists: true
[INFO] Using existing 'operadriver.exe 'binary.
[INFO] Binary 'chromedriver' exists: true
[INFO] Using existing 'chromedriver 'binary.
[INFO] Binary 'geckodriver.exe' exists: true
[INFO] Using existing 'geckodriver.exe 'binary.
[INFO] Binary 'msedgedriver.exe' exists: true
[INFO] Using existing 'msedgedriver.exe 'binary.
[INFO] Binary 'chromedriver.exe' exists: true
[INFO] Using existing 'chromedriver.exe 'binary.
[INFO] Binary 'geckodriver' exists: true
[INFO] Using existing 'geckodriver 'binary.
[INFO] Binary 'geckodriver' exists: true
[INFO] Using existing 'geckodriver 'binary.
[INFO] Setting maven property - ${webdriver.ie.driver} = C:\Users\hagit\workspace\ZafulSelMaven4\src\test\resources\selenium_standalone_binaries\windows\internetexplorerbit\IEDriverServer.exe
[INFO] Setting maven property - ${webdriver.opera.driver} = C:\Users\hagit\workspace\ZafulSelMaven4\src\test\resources\selenium_standalone_binaries\windows\operachromiumbit\operadriver.exe
[INFO] Setting maven property - ${webdriver.gecko.driver} = C:\Users\hagit\workspace\ZafulSelMaven4\src\test\resources\selenium_standalone_binaries\windows\marionettebit\geckodriver.exe
[INFO] Setting maven property - ${webdriver.edge.driver} = C:\Users\hagit\workspace\ZafulSelMaven4\src\test\resources\selenium_standalone_binaries\windows\edgebit\msedgedriver.exe
[INFO] Setting maven property - ${webdriver.chrome.driver} = C:\Users\hagit\workspace\ZafulSelMaven4\src\test\resources\selenium_standalone_binaries\windows\googlechromebit\chromedriver.exe
[INFO]
[INFO] --------------------------------------------------------
[INFO] SELENIUM STAND-ALONE EXECUTABLE DOWNLOADS COMPLETE
[INFO] --------------------------------------------------------
[INFO]
[INFO]
[INFO] --- maven-surefire-plugin:3.0.0-M3:test (default-test) @ ZafulSelMaven4 ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
Zaful_Maven_Project
Jul 13, 2020 3:12:56 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
15:12:57.230 [main] DEBUG io.github.bonigarcia.wdm.Preferences - Preference chrome=83 (valid until 2020-07-13 16:07:04)
15:12:57.241 [main] DEBUG io.github.bonigarcia.wdm.Preferences - Preference chrome83=83.0.4103.39 (valid until 2020-07-13 16:07:04)
15:12:57.242 [main] INFO io.github.bonigarcia.wdm.WebDriverManager - Using chromedriver 83.0.4103.39 (since Google Chrome 83 is installed in your machine)
15:12:57.272 [main] DEBUG io.github.bonigarcia.wdm.WebDriverManager - Driver chromedriver 83.0.4103.39 found in cache
15:12:57.273 [main] INFO io.github.bonigarcia.wdm.WebDriverManager - Exporting webdriver.chrome.driver as C:\Users\hagit\.m2\repository\webdriver\chromedriver\win32.0.4103.39\chromedriver.exe
Local Operating System: WINDOWS 10
Local Architecture: amd64
Selected Browser: chrome
Connecting to Selenium Grid: false
Starting ChromeDriver 83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103@{#416}) on port 37771
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Jul 13, 2020 3:13:01 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Entered Test 1: Open Zaful
Written screenshot to target/screenshots94642387816_Logo_Exsists.png
Entered Test 1: Open Zaful
Written screenshot to target/screenshots94642392370_Logo_Exsists.png
Entered Test 2: Blue Bikini
Written screenshot to target/screenshots94642393496_Blue_Bikini_List.png
Entered Test 3: Black Bikini Like
Passed
Entered Test 1: Open Zaful
Written screenshot to target/screenshots94642396467_Logo_Exsists.png
Entered Test 2: Blue Bikini
Written screenshot to target/screenshots94642397495_Blue_Bikini_List.png
Entered Test 3: Black Bikini Like
Passed
Entered Test 3: Refresh no Like
Passed
Entered Test 1: Open Zaful
Written screenshot to target/screenshots94642403344_Logo_Exsists.png
Entered Test 2: Blue Bikini
Written screenshot to target/screenshots94642404359_Blue_Bikini_List.png
Entered Test 3: Black Bikini Like
Passed
Entered Test 3: Refresh no Like
Passed
Entered Test 1: Open Zaful
Written screenshot to target/screenshots94642409144_Logo_Exsists.png
Entered Test 2: Blue Bikini
Written screenshot to target/screenshots94642410471_Blue_Bikini_List.png
TestJASON.json2020_07_13
[ERROR] Tests run: 14, Failures: 9, Errors: 0, Skipped: 0, Time elapsed: 36.35 s <<< FAILURE! - in TestSuite
[ERROR] Logo_Exsists(testcases.OpenZafulTest) Time elapsed: 8.149 s <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Coordinates
at testcases.OpenZafulTest.Logo_Exsists(OpenZafulTest.java:53)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.Coordinates
at testcases.OpenZafulTest.Logo_Exsists(OpenZafulTest.java:53)
[ERROR] Logo_Exsists(testcases.BlueBikiniListTest) Time elapsed: 3.539 s <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Coordinates
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.Coordinates
[ERROR] Blue_Bikini_List(testcases.BlueBikiniListTest) Time elapsed: 0.691 s <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Coordinates
at testcases.BlueBikiniListTest.Blue_Bikini_List(BlueBikiniListTest.java:39)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.Coordinates
at testcases.BlueBikiniListTest.Blue_Bikini_List(BlueBikiniListTest.java:39)
[ERROR] Logo_Exsists(testcases.LikeBlackBikiniTest) Time elapsed: 3.05 s <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Coordinates
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.Coordinates
[ERROR] Blue_Bikini_List(testcases.LikeBlackBikiniTest) Time elapsed: 1.169 s <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Coordinates
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.Coordinates
[ERROR] Logo_Exsists(testcases.NoLikesAfterRefreshTest) Time elapsed: 2.994 s <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Coordinates
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.Coordinates
[ERROR] Blue_Bikini_List(testcases.NoLikesAfterRefreshTest) Time elapsed: 0.741 s <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Coordinates
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.Coordinates
[ERROR] Logo_Exsists(testcases.JsonWriterTest) Time elapsed: 3.376 s <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Coordinates
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.Coordinates
[ERROR] Blue_Bikini_List(testcases.JsonWriterTest) Time elapsed: 1.097 s <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Coordinates
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.Coordinates
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] BlueBikiniListTest.Blue_Bikini_List:39 » NoClassDefFound org/openqa/selenium/i...
[ERROR] BlueBikiniListTest>OpenZafulTest.Logo_Exsists:53 » NoClassDefFound org/openqa/...
[ERROR] JsonWriterTest>BlueBikiniListTest.Blue_Bikini_List:39 » NoClassDefFound org/op...
[ERROR] JsonWriterTest>OpenZafulTest.Logo_Exsists:53 » NoClassDefFound org/openqa/sele...
[ERROR] LikeBlackBikiniTest>BlueBikiniListTest.Blue_Bikini_List:39 » NoClassDefFound o...
[ERROR] LikeBlackBikiniTest>OpenZafulTest.Logo_Exsists:53 » NoClassDefFound org/openqa...
[ERROR] NoLikesAfterRefreshTest>BlueBikiniListTest.Blue_Bikini_List:39 » NoClassDefFound
[ERROR] NoLikesAfterRefreshTest>OpenZafulTest.Logo_Exsists:53 » NoClassDefFound org/op...
[ERROR] OpenZafulTest.Logo_Exsists:53 » NoClassDefFound org/openqa/selenium/interactio...
[INFO]
[ERROR] Tests run: 14, Failures: 9, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 43.867 s
[INFO] Finished at: 2020-07-13T15:13:32+03:00
[INFO] Final Memory: 25M/268M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test) on project ZafulSelMaven4: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Users\hagit\workspace\ZafulSelMaven4\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
这是 testng.xml :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Test_Suite" parallel="none" thread-count="1">
<test name="Test">
<classes>
<class name="testcases.OpenZafulTest"/>
<class name="testcases.BlueBikiniListTest"/>
<class name="testcases.LikeBlackBikiniTest"/>
<class name="testcases.NoLikesAfterRefreshTest"/>
<class name="testcases.JsonWriterTest"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
我想 运行 按照他们的顺序进行测试(class 按 class),所以如果有人知道该怎么做,那将对我有很大帮助。
这就是 TestNG 的行为方式。测试不会按 testng.xml 中列出的顺序执行。您应该按要求的顺序将测试的优先级分配给 运行。如果测试相互依赖,则使用依赖。在此处查看文档。