RUVIDEO
Поделитесь видео 🙏

How To: Data Table In Cucumber Using Java (2 Min) смотреть онлайн

In this tutorial, you'll learn how to use data tables in Cucumber using Java.


Facebook: https://www.facebook.com/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");
}
}

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «How To: Data Table In Cucumber Using Java (2 Min)» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.