You are on page 1of 17
estNG class sr SING is Test Next Generalion TestNG 1S aN Unit Tesling framework used by developers to perform "Unit Tesling" also used by Aulomation Enel- E peering Lo perform « Black Roy Testing” Tn selenium We used Tesine Lo yup rou iipie test classes to generate result: @ Cap install TestNe () from Eclipse Marketplace which undey Help Menu- continue Scanned with CamScanner Goniicun ing Sova Project a ; Right click on the fava project Ge to build Path - Select add libraries » Select Testwet Click Next Click Finish tS! class :- is a Test class which contains the method develop USINS test automation. in TesiNGE class wWe do not use main() O print the Message we use Reported. leat) Tnstead OF Sysiem. out Pripiin(). Dhen we execute any TestNe class it will automatically eMerate Tesull ip HTML Formal Cemaitable- Repost) PS'de test OULPUt Folder (vefresh the java Project) Folder | un multiple test classes, we Use TegtNet. xm (guite create suite file right click ¢ op the java project goto SING Select convert 10 TestNet, ctick Finish. the suite File ight click on Testing. AM | t AS TesiNét Suite. $9 ° Ren Scanned with CamScanner Ves Tenlent of tes! 2M) < test n = 7 . Name: "Tests, os ; ISP. Dermoo"/s ined | | Oh 1. @Test ® @ After Test 2: @ Before : 3 @ After Suite ‘0 @ Data Provider '’ @Parametere : roa 3: @ Before class + @ Before Test S-@ Before Suite 2, @Op.Honay , | 6 @ After Method 3 @ Factory | 3. @ After class @ listeners x @ . + All testing annotation are present undey "testing ara : Default Execution Order of Annotation: @ Before Suite, @ Artersuite @ Beforetest® @ Beforeciass @ Beforemethod Test 5 Abtermethos Apterctass Si agtertest oh Scanned with CamScanner inet AMI esting ATL uite pame ="suite”> Ztest name: * Test"? <é1suite> testing 2 «11 Zeuite name= "Suite? Ztesthame= "Test"? Z2ClASSeS7 Zclags name = Tuesday-bemo& ly Zi testy JJeuite> olP:- Bs eT Scanned with CamScanner 3. a fstinga. xm! » | fSuite name = “suite"> éclass name= “Febi2. pemoB"/> t besting84-xml = zguite name ="Suite"> Cclass Name ="Febig, Demo « Ae L/ classes? A" I> L1test7 Scanned with CamScanner yepesk name = “ Test I"? . rss | zZiclasses? citestk> Atest name: »pemoi"> Classes éclass Name ="Feb.12.DemMosL"/> Ct Classes> Scanned with CamScanner package tes LNG} import ors: Lesling, Repor ley; hyoport ons testing annotations: Test; pubile class DeEMoA { @ Test CinvocationCount = 2) public void createuse® ( ) i 5 @Test (priority =2) Puplic void deleteUser C) f Reporiey-1og ("User Created successfully” true); Reporter. Log ("User deleted successfully” true) 5 @test n Public voig editUser( ) Reporter. Lo§(" User edited Successfully ", true) ; Scanned with CamScanner t Public class pemoc { @ test C groups. +5") Public Void CreateUser () Reporter 608 ("User createg Successfully “true), | @test (Stoup- "m") Public Void deleteuser() Reporter-Log (" user deleted Suecessfutty tre); © @ Test (group sg) Public voig editUser () Reporter Los (“sey edited success fully © trae); | ' i [3 pe input id= “Lo” type "text" vatueg =" “Disabled> |
login
Public class pemoa Static System. SetProperty(* webariver ‘chrome-driver! ” 3 "« [driver [chromedriver-eve); Public Static vorg Main (stringe Jaxgs) throws Toler ruptedexception ” driver-neur WebDriver driver =neuy ChromeDriver CJ,’ driver: MAN AEE ()- Window ('}tMaximize C); ’ Ariver-get CFilewye: Users [QS8P-/.06EAc/ Desktop.igy. himi“); ¢ AHTEY-Mangwe ). Windors Uratey-jbod at ie » driver: FindELtement (Bysid C't2")-gendkeys (" Vaishnaw'")5 Scanned with CamScanner sublic class DEMOA { static | System. seiProperty ('webdriver.chrome.dviver"" * [driver [chromariver @x2)7 j @ Test . Public void test ( ) { WebDriver driver= new ChromeDriverC) >, river get ("http://w Segsie: com’); String actual = driver. Bettitle’) ; Shing expected =, "Goggle"; Tf (actual: equals Cexpected)) f Reposter. Log ("Pass.:.",true);’ else Reporter: Log ("Fail true)s Assert. fail C)5 3 Ariver-close C) 5 Scanned with CamScanner “att nD Tesla a How cdo you perform verificalion | S Using Assert class - aaa Public clags DeMoA PUblfe vorg teste) a iver De Ativer SetChtep “MO String actual = iver veititze O; String expected: "hy ley, Asserk. assertequats (ac tual, EXP ected). if Cactual. equats CexPectea)) Reporter los (Pass. “truey Pw Boogie, Cony"), ise , Reporter. log (“Fail. .", Lruey Assert: faill) wo Chrome Driverc yt Static f ( System ‘setProperty Owebariver. chrome criver 3 ‘driver/chromectriver.cxe) @Test Scanned with CamScanner ot execute remain nS slate- |Ppen «we USE Assert Tt will po F comparison bails mens of currest ‘lestMethod i a ne “public class DEMoA @Test Public void-testA().- t Reporter Lo8(" Start desta ivued> . Assert assert Equals (tabe”s* aff 5 Reporter: Lag ("End testa true) 5 @Test ‘public vord testBC 3 " Stavt tests’, true); t Reporter. Lost Spruedy i 4 Reporter Laat” End tesiB' i if ' 3 To continue the execu SOfE ASS ert Which has N tin soft assert 40 report at the end as shown below - tion even fF comparison fails we use on-Static Method. the Status we Should use Assert helt 1 : | Scanned with CamScanner ‘ y 7 } Public clags DEMoA ' { | © Test ' Public void testAt ) j { SoftAssert g- New SortAssert() 5 .| 8 Re porter. Log ("Stavt testa”, true), i P S-AssertEquats (" abe", "xz"), \ Reporter. Los (" End testa” true);- S-assertall 0), 5 @Test Public void testa) Reporter. log (“Start testa”, true); « Reporter. Log (“End tests’, true); 3 Note i> * ip fo verify basic & critica) teature we use agsert: & j od aurother places we use goftAscerk. bi Scanned with CamScanner Spen the browser, entey the vel Lagin pageshoul d be displayed we can't continue > use Assevt enter valid UN, Plo € K losin Open the browser, enter the URL Legin page should be displayed . verify the status of check box check box should be selected we can continue > use Soft Asset verify the sstatus of button Button should be enabled Scanned with CamScanner Assert Soft Assert “AU tbe methods ave + All the methods are Static Non-static wWe do not call * We Should call ' assertAll() assertAl () |i | + TE will pot execute «TE wit execute | Temaining stateme- remaining stateme. | nts of current test “pt even Fe comparison | : ; | Method, if com parison hails. 4 | bails- b u a AO you execute testcy only When another test(Jis | ass 2 | using dependsonmethods Public class pemoa re t @test Public voig loging ) Reporter. 108 (“logins tr y true), Asseit - “FailC), s @Test Cdependsonmethods= =C*login")) Public void logout Os - Reporter Log (*iggaut" true), Scanned with CamScanner

You might also like