162. 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 'WebDriver-Project79' in Eclipse IDE
2. Configure the Project to work with Selenium WebDriver
3. Create a package say 'package79' under the newly created project.
4. Create a Java Class file say 'Class79' 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. Save and Run the 'Class79.java' file by selecting the 'TestNG' option as shown below:




3. Observe that all the three tests inside a single Test Method 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.


Followers

Labels