154. Non-Refactored Selenium Automation Code using TestNG framework






Lets write the Selenium Automation Code without Refactoring it.
Lets make sure that our code contains more than one tests.
Lets include TestNG annotations in our code and later Run using 'TestNG'.

Test Description:



Implement this on Eclipse IDE using TestNG framework:

Pre-requisites:

1. Create a new Project say 'RC-Project66' in Eclipse IDE
2. Configure the Project to work with Selenium RC
3. Configure the Selenium Standalone Server to run from Eclipse IDE
4. Start the Selenium Standalone Server
5. Create a package say 'package66' under the newly created project.
6. Create a Java Class file say 'Class66' under the newly created package as shown below:



Actual Steps:

1. Write the following code into the newly created Java Class file as shown below and make sure that you resolve all the errors before going to next step: (Write three tests inside a single test method)



2. Start the Selenium Standalone Server
3. Save and Run the 'Class66.java' file by selecting the 'TestNG' option as shown below:




4. Ensure that all the three tests in our Automation code are passed as shown in the below video:


Watch the below video:

Click here to watch the video.

Download this Project:


Click here to download this project and import into Eclipse IDE  on your machine.




Is it ok to write three tests in a single Test method instead of writing them in separate test methods?

The answer is No. Though the Test runs without any errors even if we mention more than one tests in a single test method, its not a good practice to write more than one test  into a single test method.

So what we have to do in order to overcome this ?

We've to write each and every test into a separate test method.


Please comment below to feedback or ask questions.

Only one test should be written inside a single test method will be explained in the next post.


No comments:

Post a Comment

Followers

Labels