File tree Expand file tree Collapse file tree 3 files changed +31
-11
lines changed
src/com/cucumbersample/test Expand file tree Collapse file tree 3 files changed +31
-11
lines changed Original file line number Diff line number Diff line change
1
+ <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
2
+ <suite name =" Sanity" parallel =" methods" >
3
+ <test name =" Test1" >
4
+ <groups >
5
+ <run >
6
+ <include name =" SearchTest_Sample1" />
7
+ </run >
8
+ </groups >
9
+ <packages >
10
+ <package name =" com.cucumbersample.test.*" />
11
+ </packages >
12
+ </test >
13
+ </suite >
Original file line number Diff line number Diff line change 4
4
import cucumber .api .CucumberOptions ;
5
5
import cucumber .api .testng .TestNGCucumberRunner ;
6
6
7
- @ CucumberOptions ( features = { "src/test/resources/" }, tags ={ "@Search1" })
7
+
8
8
public class RunAsTestNgTest {
9
9
10
- /**
11
- * Create one test method that will be invoked by TestNG and invoke the
12
- * Cucumber runner within that method.
13
- */
14
-
15
- @ Test (groups = "examples-testng" , description = "Example of using TestNGCucumberRunner to invoke Cucumber" )
16
- public void runTest () {
17
- new TestNGCucumberRunner (getClass ()).runCukes ();
10
+ @ CucumberOptions (features = {"src/test/resources/" },tags ={"@Search1" })
11
+ public class SearchTest1 {
12
+ @ Test (groups = "SearchTest_Sample1" , description = "Example of using TestNGCucumberRunner to invoke Cucumber" )
13
+ public void SearchTest_Sample1 (){
14
+ new TestNGCucumberRunner (getClass ()).runCukes ();
15
+ }
18
16
}
19
17
18
+ @ CucumberOptions (features = {"src/test/resources/" },tags ={"@Search2" })
19
+ public class SearchTest2 {
20
+ @ Test (groups = "SearchTest_Sample1" , description = "Example of using TestNGCucumberRunner to invoke Cucumber" )
21
+ public void SearchTest_Sample2 () {
22
+ new TestNGCucumberRunner (getClass ()).runCukes ();
23
+ }
24
+ }
20
25
}
Original file line number Diff line number Diff line change 6
6
import org .openqa .selenium .WebDriver ;
7
7
import org .openqa .selenium .WebElement ;
8
8
import org .openqa .selenium .chrome .ChromeDriver ;
9
+ import org .testng .annotations .AfterMethod ;
10
+ import org .testng .annotations .BeforeMethod ;
9
11
import org .testng .annotations .BeforeTest ;
10
12
import cucumber .api .java .After ;
11
13
import cucumber .api .java .Before ;
@@ -17,15 +19,15 @@ public class StepDefinition {
17
19
18
20
protected WebDriver driver ;
19
21
20
- @ Before
22
+ @ BeforeMethod
21
23
public void setUp () {
22
24
System .setProperty ("webdriver.chrome.driver" , "C:/Softwares/chromedriver_win32_2.2/chromedriver.exe" );
23
25
driver = new ChromeDriver ();
24
26
driver .manage ().timeouts ().implicitlyWait (30 , TimeUnit .SECONDS );
25
27
driver .manage ().window ().maximize ();
26
28
}
27
29
28
- @ After
30
+ @ AfterMethod
29
31
public void tearDown () {
30
32
driver .close ();
31
33
}
You can’t perform that action at this time.
0 commit comments