GoogleTest.groovy
import com.myCompany.pages.GooglePage
import geb.testng.GebReportingTestTrait
import geb.testng.GebTestTrait
import org.testng.annotations.*
class GoogleTest implements GebReportingTestTrait {
@BeforeClass
void setupClass () {
println("GoogleTest @BeforeClass started")
long id = Thread.currentThread().getId()
println("setupClass. Thread id is: " + id)
}
@Test
void testGooglePage() {
long id = Thread.currentThread().getId()
println("testGooglePage. Thread id is: " + id)
go 'https://www.google.com/'
at GooglePage
}
}
GebManualTest.groovy
import com.wellTrack.pages.GebishOrgHomePage
import com.wellTrack.pages.TheBookOfGebPage
import geb.testng.GebReportingTestTrait
import geb.testng.GebTestTrait
import org.testng.annotations.BeforeClass
import org.testng.annotations.Test
class GebManualTest implements GebReportingTestTrait {
@BeforeClass
void setupClass () {
println("@BeforeClass started.")
long id = Thread.currentThread().getId()
println("setupClass. Thread id is: " + id)
}
@Test
void testCanGoGebManual() {
long id = Thread.currentThread().getId()
println("testCanGoToLoginPage. Thread id is: " + id)
to GebishOrgHomePage
GebishOrgHomePage gebishOrgHomePage = page
gebishOrgHomePage.manualsMenu.open()
//first link is for the current manual
assert manualsMenu.links[0].text().startsWith("current")
manualsMenu.links[0].click()
at TheBookOfGebPage
}
}
testng.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Test-class Suite" parallel="classes" thread-count="2" >
<!--<listeners>
<listener class-name="com.example.listeners.TestListener"/>
</listeners>-->
<test name="Test-class test" >
<classes>
<class name="com.myCompany.tests.GebManualTest"/>
<class name="com.myCompany.tests.GoogleTest"/>
</classes>
</test>
我想在同一个线程中运行同一个类中的所有方法(尽管在上面的示例中,我每个类只有 1 个方法),但是每个类都将在单独的线程中运行。
上面的配置似乎不起作用,这些方法在同一个线程中按顺序运行。上面的配置有什么问题吗。