Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the nature and example of cucumber?

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you the nature of cucumber and how the examples are. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Noun interpretation Feature

Feature is the beginning of all tests. It is followed by a descriptive text indicating what the test file is for.

Description

Description is an extensible text description that can be followed under Feature, Example, Background, Scenario, and Scenario Outline.

Example and Scenario

Example and Scenario are a pair of synonyms, a specific test case that contains multiple step. In general, it is made up of Given (given an initial condition), When (what happened), and Then (what is the result).

Steps

Step is the smallest unit of cucubmer, and each step is composed of Given, When and Then.

Example Feature: merchant management test Scenario: login test Given open login address "https://localhost:8080/sso/login" When login link is normal Then login has tokenpublic class LoginStepdefs {private String token; private Response response; @ Given (" open login address {string} ") public void opens login address (String url) {System.out.println (" url = "+ url) InputStream inputStream = getClass () .getResourceAsStream ("/ io/cucumber/mryt/srm/login.json"); response = given () .body (inputStream) .with () .contentType (ContentType.JSON) .config ((RestAssured.config (). SslConfig (new SSLConfig (). RelaxedHTTPSValidation () .post (url) } @ When ("whether the login link is normal") whether the public void login link is normal () {System.out.println ("response.getBody (). AsString () =" + response.getBody () .asString ()); response.then () .assertThat () .statusCode } @ Then ("whether there is token after login") is there any token () {token = response.path ("data.token"); Assert.assertTrue (StringUtils.isNotBlank (token)) after public void login;}} the above is the nature of cucumber and what the examples are like. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report