There is a connected graph G(V, E) and the weight or cost for every edge is given. Kruskal’s algorithm will find the minimum spanning tree using the graph and the cost.It is merge tree approach. Initially there are different trees, this algorithm will merge them by taking those edges whose cost is minimum, and form a single tree.In this problem, all of the edges are listed, and sorted based on their cost. From the list, edges with minimum costs are taken out and added in the tree, and every there is a check whether the edge forming cycle or not, ... Read More
We can do single data parametrization without using Examples in Cucumber by passing the value directly in the feature file.ExampleFeature file.Feature: Tutorialpoint Job page Scenario: Tutorialpoint job page look and fee Given Launch site https://www.tutorialspoint.com/about/about_careers.htm Then Verify the tabs on the pageURL is directly passed in the Given statement in the feature file.The step definition file should have the mapping of the Given statement.Example@Given (“^Launch site \"([^\"]*)\"$”) public void launchJobsite(String url){ System.out.println("url is : " + url); } @Then (“^Verify the tabs on the page"$”) public void tabverification(){ System.out.println("Tabs verified successfully); }@Given (“^Launch site \"([^\"]*)\"$”) passes the UR ... Read More
The glue is a part of Cucumber options that describes the location and path of the step definition file.ExampleTest Runner file.import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; import cucumber.api.testng.AbstractTestNGCucumberTests; @CucumberOptions( features = "src/test/java/features", glue="stepDefinations" ) public class TestRunner extends AbstractTestNGCucumberTests { }
We can use regular expressions in Cucumber for selecting a collection of similar statements in the feature file.Examplefeature fileFeature: Exam Syllabus Scenario Outline: Summer and Winter Exam Schedule Given Exam time table in summer season Given Mathematics and Physics Syllabus Given Exam time table in winter seasonThe step Definition file has @Given("^Exam time table in ([^\"]*) season$") which maps two Given statements in a Feature file with the help of regular expression.Example@Given ("^Exam time table in ([^\"]*) season$") public void timeTable(String season){ if (season.equals("winter")){ System.out.println("The winter syllabus"); }else{ System.out.println("The summer syllabus"); ... Read More
We can run precondition and postcondition test methods with the help of @Before and @After hooks in Cucumber.ExampleFeature file.Feature: Transaction Table Scenario: Verify the monthly transactions Given User is on the Payment PageStep Definition has methods with hooks @Before and @After. The test method with hook @Before will be executed as a precondition then the test method (naviagteToPayment() method) will run and finally the test method with hook @After which is the postcondition will execute.Example@Before public void method1(){ System.out.println("The precondition executed successfully"); } @After public void method2(){ System.out.println("The postcondition executed successfully "); } @Given ("^User is on payment ... Read More
We can include and exclude test methods from a set of test cases in Cucumber by tagging scenarios in the feature file.ExampleFeature file.@Tutorialspoint Testing Feature: Login Feature Testing @Smoke Scenario: Home Page Testing Given User is in home page @CodingModule Scenario: Coding Module Testing Given User is in Coding Module PageThe test runner file has tags Smoke to be excluded and CodingModule to be included in the execution.Exampleimport org.junit.runner.RunWith; import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; import cucumber.api.testng.AbstractTestNGCucumberTests; @RunWith(Cucumber.class) @CucumberOptions( features = “src/test/java/features”, glue = “stepDefiniations” tags = {“~@Smoke”, “@CodingModule”} )Read More
We can skip a particular test method from execution in Cucumber with the help of tagging of scenarios in the feature file.Examplefeature file.@Regression Feature: Invoice Testing @Smoke Scenario: Login Verification Given User is in Home Page @Payment Scenario: Payment Testing Given User is in Payment PageFeature file with scenarios having tags Smoke and Payment.Exampleimport org.junit.runner.RunWith; import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; import cucumber.api.testng.AbstractTestNGCucumberTests; @RunWith(Cucumber.class) @CucumberOptions( features = “src/test/java/features”, glue = “stepDefiniations” tags = { “~@Payment”} )To skip the scenarios with @Payment , ~ is placed before the @Payment tag in Test Runner file.Read More
We can set the order of execution for test methods in Cucumber with the help of order keyword. Test methods are assigned with order in the step definition file.The test method with lower order executes first followed by the methods with higher orders.ExampleStep definition file.@Before (order = 1) public void login(){ System.out.println("login is successful"); } @Before (order = 2) public void payment(){ System.out.println("payment is successful"); } @Given ("^Land in repayment page$") public void repay(){ System.out.println ("Actual Scenario of repayment"); }The test method with lower order (login() set to 1) will be executed first. Then payment () test ... Read More
We use the Scenario Outline keyword in the feature file in Cucumber. If a particular scenario needs to be executed with more than a set of data in multiple combinations, then we use the Scenario Outline.The multiple data sets are represented in form of a table separated by (||) symbol under Examples keyword. Each row represents a group of data.ExampleFeature file.Feature: Login Verification Feature Scenario Outline: Login Verification Given User lands on the home page When Page title is Tutorialspoint Then User keys in "" and "" Examples: | username | password | | Selenium | t123 ... Read More
The main file components in Cucumber are listed below −Feature file − This file has an extension of .feature. It comprises single or multiple test scenarios in plain text. All the scenarios are written with the keywords like Then, Given, When, And, But, Feature, Background and so on.ExampleFeature file.Feature: Login Test Scenario: Tutorialspoint login validation Given: Launch the “https://www.tutorialspoint.com/index.htm”Step Definition File - This file has an extension of .java. It provides mapping of the test scenarios to the test script logic.ExampleStep Definition file based on the above feature file.@Given (“^Launch the \"([^\"]*)\"$”) public void launch_application(String url){ System.out.println("The url is ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP