Showing posts with label Best Online Training Provider. Show all posts
Showing posts with label Best Online Training Provider. Show all posts

Monday, April 20, 2020

TestNG Tutorial Advanced Topics - Part 5

Tutorial Agenda

1> Exclude-Include:- TestNG provides the feature of enabling and disabling the test cases. We can disable a set of test cases from getting executed. 

For example, we have scenario where a serious bug occurs in a feature due to certain tests, so we need to disable the test cases from being executed.

You can disable or exclude the test cases by using the enable attribute to the @Test annotation and assign False value to the enable attribute.

Syntax: @Test(enabled=false)

We can achieve this thing in two way as below:

1> We can add value in the @Test annotation as below:

Example:


Result:


2> We can add Exclude tag into the testng.xml file:

Example:



Result:









😀 
TIME TO IMPLEMENT the Same IN YOUR ECLIPSE NOW😀 

2> DependsOnMethods: dependsOnMethods attribute on a test method [test1 e.g.] specifies all the test methods [test2, test3,..] this test method depends on. 

It means test1 will start execution only after all the tests it depends on executed successfully. 

If any of the tests specified via dependsOnMethods attribute failed, then test1 will be skipped.

alwaysRun attribute on a test method to true forces the execution of this test even if the tests it depends on were failed.

Example: In below class we have four test method and last two depends on first two method.

1> testAdd(): Everything is fine with code, This will PASS

2> testDivide(): Intentionally we given wrong logic to divide number by 0, hence this will FAIL.

3> testProcessRealNumbers(): This method depends on both above methods to pass.

dependsOnMethods={"testAdd", "testDivide"}

So this will get SKIPPED as second method going to FAIL.

4> testProcessEvenNumbers(): This method again depends on both above methods to pass, also we have added ALWAYS RUN as True means this will pass the test method even one of the method from dependsOn is fail.

Sample Code:

Result as described above:


😀 TIME TO IMPLEMENT the Same IN YOUR ECLIPSE NOW😀 

3> TestNG Listeners: 

TestNG provides the @Listeners annotation which listens to every event that occurs in a selenium code. 

Listeners are activated either before the test or after the test case. 

It is an interface that modifies the TestNG behavior. For example, when you are running a test case either through selenium or appium and suddenly a test case fails. 

We need a screenshot of the test case that has been failed, to achieve such scenario, TestNG provides a mechanism, i.e., Listeners. When the test case failure occurs, then it is redirected to the new block written for the screenshot.

Listeners are implemented by the ITestListener interface. 

An ITestListener interface has the following methods:



Below is the description of all listeners methods:

onTestStart(): An onTestStart() is invoked only when any test method gets started.
onTestSuccess(): Method is executed on the success of a test method.
onTestFailure(): Method is invoked when test method fails.
onTestSkipped(): Method run only when any test method has been skipped.
onTestFailedButWithinSuccessPercentage():Method is invoked each time when the test method fails but within success percentage.
onStart(): Method is executed on the start of any test method.
onFinish(): Method is invoked when any test case finishes its execution.

Let's Implement this:

First, We need to create one Listener class which contains all methods definition and print line information.

Sample Definition should be as below:


Below is the definition of all method on above class.


Now, Create actual test case which contains TEST method here.
Need to call that listener as shown below:

@Listeners(All_Practicals.Listerner_ITestListener.class)


Once you run the test then it will add some extra line into the log as below.



😀 TIME TO IMPLEMENT the Same IN YOUR ECLIPSE NOW😀

Reference Site:https://www.javatpoint.com/

TestNG Tutorial Advanced Topics - Part 4

TestNG Parameters are the arguments that we pass to the test methods. 

Parameterisation is always helpful in any application to store the key values into the file and call it whenever required across the application, there are two ways through which we can pass the parameters to the test methods:


  • TestNG Parameters
  • TestNG DataProviders


In this topic, we will learn about the TestNG Parameters. We will learn about the parameterisation in the xml file.

Suppose we want to set the global variables such url settings, username, password or API Keys, there are some values which are constant in all the test cases, in such case we use the TestNG Parameters.

1> TestNG @Parameters – test parameters with testng.xml

You already know about testng.xml File. If not then Click Here.

Now, we need to store username and password in testng.xml file and need to pass it to class called 'Parameterized_Keyword'.

So we have added two parameter tags here in testng.xml.




Now, Below way we can call these two parameters using @Parameters annotation in Parameterized_Keyword.Java class.





Note: testng.xml parameter name should match with name we are passing into class file under @Parameter annotation to call it.

😀 TIME TO IMPLEMENT the Same IN YOUR ECLIPSE NOW 😀

2> TestNG @DataProvider – dataProvider in the class itself

A test method that uses DataProvider will be executed a multiple number of times based on the data provided by the DataProvider

The test method will be executed using the same instance of the test class to which the test method belongs.

Marks a method as supplying data for a test method. The annotated method must return an Object[ ][ ], where each Object[ ] can be assigned the parameter list of the test method. 

The @Test method that wants to receive data from this DataProvider needs to use a dataProvider name equals to the name of this annotation.

Lets understand this by example practically.

We have one TestNG Class, Which contains below @DataProvider having name=SearchProvider.



It contains two dimensional Object array to pass the element values . Hence return values show the same.

This will pass the value to @Test method one by one.

Now, we have one @Test method in the same TestNG class. We pass the dataProvider using the same name as we have given in @DataProvider to pass the values one by one.



Below is the result when we run this code. Console & TestNG Result.




😀 TIME TO IMPLEMENT the Same IN YOUR ECLIPSE NOW 😀


~~~~ Other TestNG Related Tutorial Links~~~~

TestNG Tutorial - Introduction Part

TestNG Tutorial Advanced Topics - Part 1 (Configuration of TestNG)

TestNG Tutorial Advanced Topics - Part 2 (TestNG.XML File)

TestNG Tutorial Advanced Topics - Part 3 (Priority, Groups, Parallel Mode, invocationCount, ThreadPool)

TestNG Tutorial Advanced Topics - Part 4 (Parameterization, Data Provider)

TestNG Tutorial Advanced Topics - Part 5 (Exclude,Listeners,DependsOnMethod)



TestNG Tutorial Advanced Topics - Part 1

We are now going to learn more advance stuff about the TestNG in this tutorials.

In first tutorial of TestNG (Introduction of TestNG), you get enough knowledge how to install, configure and different annotations.


Default Project Folder Structure With TestNG Library





Let's see the difference on JAVA class and TestNG class.


Below is difference in Option when you try to run the Java Class and TestNG Class.


TestNG Class: Similar to Java class but dont contains Main Method and contains different annotations to run as testng class.



Note: We never use Main Method in TestNG Class.


Java Class Run





TestNG Class Run






How TestNG Change the Reporting in Selenium: Main Benefits of TestNG

Without TestNG: In Selenium without TestNG we have to add required PRINT LINE statements to verify that we are on right track or not or we need to print same information back and forth to excel or other files.


Without TestNG - When we run the Selenium Script, we can see output in Console.





With TestNG - We can see the complete format of how many test case run, pass, failed and skipped.




Also one separate folder 'test-output' get generated every time we run TestNG class and it has different kind of reports. 




Mostly used format is 'Index.html' which display below structure in browser.


TestNG Tutorial Advanced Topics - Part 2

What is TextNG.XML?

In simple term testng.xml is heart of testng class. It contains all key information about the project. If you want to make any customization on your program to run you can do it from here.

It is very useful to organize the priorities of many thing while running your program. Like Groups, Include, Exclude, Parallel, Parameters etc.

Benefits of Testng.XML file:


  • It allows to pass parameters to the test cases
  • Allows to add group dependencies
  • Allows to add priorities to the test cases
  • Allows to configure parallel execution of test cases
  • Allows to parameter the test cases
  • TestNG listeners can be implemented at Suite level
  • To Integrate TestNG framework with third party tools like Jenkins testng.xml is required
  • Testng.xml file allows to include or exclude the execution of test methods and test groups

How to Generate Textng.xml file for the Project:

Step 1 : Select your project folder in which you have all the packages.

Step 2 : Right click on selected project folder.

Step 3 : Mouse hover on TestNG option from the given list which is located at the bottom.

Step 4 : Select "Convert to TestNG" option.



Step 5 : A modal will appear with the name of "Generate testng.xml" 

You can give name, select parallel mode and thread count if you want to add them by default while creating file.




Sample Format of TextNG.XML






Sunday, April 19, 2020

Events by SLT Learning


Past Events


Event Name:  Quick Session on Software Testing
Event Type: Training 
Purpose: Sharing Knowledge about Testing
Date: 05-July-2020, Sunday
Time: 07 PM to 08 PM IST

Speakers & Hosts:

Mr. Ankit Prajapati (Automation Engineer - SLT Learning)

Topics to Cover for Understanding:

  • Software Testing
  • Level of Testing
  • Types of Testing
  • SDLC
  • Waterfall - Agile Model
  • STLC
  • Defect Life Cycle
  • Test Scenario - Test Cases


Video Link: 


--------------------------------------------
Event Name:  Quick Session on Selenium Part 2
Event Type: Training 
Purpose: Sharing Knowledge about Selenium
Date: 16-May-2020, Saturday
Time: 08 PM to 09 PM IST

Speakers & Hosts:


Mr. Ankit Prajapati (Automation Engineer - SLT Learning)
Topics to Cover for Understanding:
  • POM
  • Cucumber
  • API Testing
  • Database Testing
How to connect to Webinar:

Topic: SLT Learning - Free Demo Session - 2
Time: May 16, 2020 10:30 AM Eastern Time (US and Canada)

Join Zoom Meeting
https://us04web.zoom.us/j/5088231631?pwd=TXdocGl6Y0FNa2VsS3V2cHFGLzlOQT09

Meeting ID: 508 823 1631
Password: 3x0Z9a

Few Notes from Trainer:
  • This is not on regular basis as i spare my time to help people to start learning by themselves.
  • You can find different mediums to contact us on signature 
  • Follow, Like and Subscribe to access Videos, Tutorials for Free of Cost (I am uploading this materials one by one)
Follow below things for better training:


  • Keep Yourself Mute (Reduce the Disturbance) - Otherwise I have to remove to maintain the quality
  • This is quick session for all to cover almost all topics fundamental
  • Try to join with computer Audio and Be on alone environment to listen clear voice
  • If you have any disturbance the voice or video, dont disturb on call as it is recording session.
  • If you missed this seminar then watch the complete recording on our YouTube channel.

Video Link: 



--------------------------------------------

Event Name:  Quick Session on Selenium Part 1
Event Type: Training 
Purpose: Sharing Knowledge about Selenium
Date: 25-April-2020, Saturday
Time: 08 PM to 09 PM IST

Speakers & Hosts:


Mr. Ankit Prajapati (Automation Engineer - SLT Learning)
Topics to Cover for Understanding:
  • GIT
  • Selenium IDE
  • Selenium WebDriver
  • Selenium Grid
  • Data Driven and Keyword Driven Frameworks Understanding
  • TestNG
  • Maven
  • Cucumber
  • API
  • Database Testing
How to connect to Webinar:

You have been invited to an online meeting, powered by Amazon Chime.https://chime.aws/7757205755
Meeting ID: 7757 20 5755
U.S. Toll: +1 206-462-5569
Meeting PIN: 7757 20 5755

International: https://chime.aws/dialinnumbers/  

Few Notes from Trainer:
  • This is not on regular basis as i spare my time to help people to start learning by themselves.
  • You can find different mediums to contact us on signature 
  • Follow, Like and Subscribe to access Videos, Tutorials for Free of Cost (I am uploading this materials one by one)


Video Link: 



--------------------------------------------

Event Name: Webinar SLT Learning : AutonomIQ ChroPath - The Best XPath & Time Saver Tool in Market
Event Type: Webinar
Purpose: Sharing Knowledge about ChroPath
Date: 18-April-2020, Saturday
Time: 09 PM to 10 PM IST

Speakers & Hosts:



Hosted By : Mr. Ankit Prajapati (Automation Engineer - SLT Learning)

Co-Hosted By : Mr. Sanjay Kumar ( Inventor & Creator of ChroPath | Product Evangelist  @AutonomIQ)



Joining Details:



https://chime.aws/7757205755

Meeting ID: 7757 20 5755

U.S. Toll: +1 206-462-5569

Meeting PIN: 7757 20 5755

International: https://chime.aws/dialinnumbers/