Introduction to Junit in Selenium
It is a java unit testing framework
The purpose of J unit is to write the test scripts in java programming language and scripts can be executed by default
** write a program to register and login into mail.in.com by using j unit ?
Right click on the project àclick on new àselect J unit test cases
Give the package name as “ j unit “ & class name as “mail tag,x-right”
check the check boxes setup() & teardown()à click on finish
Any import statements are activations
J-Unit life cycle [execution flow]:-
it contains the anirations like @before,@after,@test etc.
It contains a setup method which acts like a precondition
It contains teardown (or)shut down method which acts as a post condition.
It is responsible to develop the test scenario where it acts like a main method
For each and every scenario we need to develop with test animation.
when we run the script initially it invokes @before, @after, @test methods .
- The same process will be continued for all the @ test methods.
- once the execution is done it provides the results under the J-unit section.
Inclined to build a profession as Selenium Developer? Then here is the blog post on
Batch execution/suite execution:
combination of multiple test cases [scenarios]is known as a batch or test suite
- Take how classes and execute both the classes methods in a sequential order.
- Right click on project àclick Newà select J unit test caseà implement the class
- Take one more class and follow above steps
- To run all the classes right click à click on run as à select run configuration
- Select the radio button “run all test in the…” à click on apply à click on run
Limitations of J-unit:-
It is having very limited annotations like @before class, @before, @test, @after ,after class
- Each and every test @before will be applicable
- It is having option to run either a single test or all classes
- Not having option to run the specific classes
- Once the execution is completed it is providing the result in j-unit section of explain but not in any external field execute for the reporting.
- All the above limitation can be overcome by using test NG.
- It is testing framework inspired and advance version of J-unit.
- The limitation which are in J-unit are overcome and added new features that mode test NG more power here and easier to use.
- Test NG is an add-on for eclipse.
Steps to install testing in Eclipse:
Go to eclipse à click on help select install new software click on add give name on ”Test NG” à provide URL as http://best.com/eclipse -- >click ok à check the check box “Test NG” click on next again next click on radio button “I accept the license” click on finish click ok on security warning manage click yes in restart message
* Write a program to handle the pop –up in spice jet.com by using web driver with testing *
Take a Test NG class by right click on he project à click on test NG select create Test NG class
Click on browse folder on source folder expand the project and select “SRC” then click on ok
Give the package name on “spice jet _ Test NG”
Give the class name on “spice jet _ popup”
Check the check boxes @ before test and @ After test
Click on finish
Learn more about Selenium Interview Questions in this blog post.
Test NG life cycle[execution flow] :-
It contains multiple anitations like @before test, @after test, @test e.t.c
when we run the scripts initially it invokes @before test method then executes an the @test methods in a alphabetical order finally it executes @after test method.
once the execution is done it provides the results in two formats .
- In console
- MISSING LAST LINE PG:43
E:\ work space loan\ selenium \ test. output \ default suite\ default test. Home
Result o/p file [external file]
To perform the test scripts execution we are planning to use xml files.
we can run the test methods in user defined order [we can avoid alphabetical order issue]
we can perform batch execution
we can provide user defined names to default suite folder and default test html file.
How to create on XML file:
Go to file click on new select other à expand XML folder select XML file click on next select the project
Xml file Format:-
<suite name =”spicejet suite” >
<test name=”spicejet test results” >
<include name=”verifyone way search”> </include>
For an Indepth knowledge on Selenium, click on below