ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

How To: Data Table In Cucumber Using Java (2 Min)

cucumber tutorial

cucumber datatable

cucumber bdd

cucumber tutorials

cucumber java tutorial

cucumber java

bdd framework

cucumber tutorial for beginners

data tables in cucumber

data driven testing in cucumber

Автор: Gokce DB

Загружено: 2022-07-10

Просмотров: 387

Описание: In this tutorial, you'll learn how to use data tables in Cucumber using Java.

—
Facebook:   / gokcedbsql  
—
Video Transcript:
—
Hi guys, this is Abi from Gokcedb. In this video, you’re going to learn  How to use a Data Table in Cucumber using Java. Let’s start by looking at the test Directory Structure under the Java folder. 

I have a Hello Cucumber Package with a bunch of Java files under the resources folder. I have a Hello Cucumber package with two feature files. Now, let’s look at one of the feature files. Online 1, I have the name of the feature, and on line 2, I have a description. 

In line 4, I’m defining the scenario with three steps given, when and then. In my when step, I have a data table with the column headers of username and password with two rows. Next, let’s look at the step definition file. 

On line 37, I’m defining the at-when step. Here, I'm using the data table dot as a Map Method to convert the table to a list of maps. For each row of the table, a map is created containing a mapping of column headers to the column cell of that row. 

In this for loop, I’m looping through all the rows of the table and printing the username and password. Finally, on line 47, I’m defining the at-then step and printing the login successful message. Next, to execute this test, right-click on the feature file and hit run. 

As you can see, we were successfully able to access and print the data table values. There you have it. Make sure you like, subscribe, and turn on the notification bell. Until next time.

Feature: Authentication
Successful authentication validation

Scenario: Successful authentication with valid credentials
Given user is on the login page
When user enters credentials to login
| username | password |
| user1 | passkey123 |
| user2 | passkey345 |
Then Message displayed Login Successful

package hellocucumber;

import io.cucumber.datatable.DataTable;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.When;
import io.cucumber.java.en.Then;

import java.util.Map;

import static org.junit.jupiter.api.Assertions.*;

public class StepDefinitions {
private String today;
private String actualAnswer;

@Given("today is {string}")
public void today_is(String today) {
this.today = today;
}

@When("I ask whether it's Friday yet")
public void i_ask_whether_it_s_Friday_yet() {
actualAnswer = IsItFriday.isItFriday(today);
}

@Then("I should be told {string}")
public void i_should_be_told(String expectedAnswer) {
assertEquals(expectedAnswer, actualAnswer);
}

@Given("user is on the login page")
public void user_is_on_login_page() {
// Write code here that turns the phrase above into concrete actions
System.out.println("On login page");
}

@When("user enters credentials to login")
public void user_enters_credentials_to_log_in(DataTable dataTable) {
// dataTable.asMaps converts the table to a list of maps
// For each row of the table a map is created containing a mapping of column headers
// to the column cell of that row
for (Map[REMOVED]String, String[REMOVED] data : dataTable.asMaps(String.class, String.class)) {
System.out.println("username: " + data.get("username"));
System.out.println("password: " + data.get("password"));
}
}
@Then("Message displayed Login Successful")
public void message_displayed_login_successful() {
// Write code here that turns the phrase above into concrete actions
assert true;
System.out.println("Login Successful");
}
}

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
How To: Data Table In Cucumber Using Java (2 Min)

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]