Cucumber

Overview

总结一下Cucumber的通常用法

Keywords

Each line that isn’t a blank line has to start with a Gherkin keyword, followed by any text you like. The only exceptions are the free-form descriptions placed underneath Example/Scenario, Background, Scenario Outline and Rule lines.

The primary keywords are:

Feature
Rule (as of Gherkin 6)
Example (or Scenario)
Given, When, Then, And, But for steps (or *)
Background
Scenario Outline (or Scenario Template)
Examples (or Scenarios)
There are a few secondary keywords as well:

“”” (Doc Strings)
| (Data Tables)
@(Tags)
# (Comments)

Feature File Sample

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Feature: Multiple site support
Only blog owners can post to a blog, except administrators,
who can post to all blogs.

Background:
Given a global administrator named "Greg"
And a blog named "Greg's anti-tax rants"
And a customer named "Dr. Bill"
And a blog named "Expensive Therapy" owned by "Dr. Bill"

Scenario: Dr. Bill posts to his own blog
Given I am logged in as Dr. Bill
When I try to post to "Expensive Therapy"
Then I should see "Your article was published."

Scenario: Dr. Bill tries to post to somebody else's blog, and fails
Given I am logged in as Dr. Bill
When I try to post to "Greg's anti-tax rants"
Then I should see "Hey! That's not your blog!"

Scenario: Greg posts to a client's blog
Given I am logged in as Greg
When I try to post to "Expensive Therapy"
Then I should see "Your article was published."

Scenario Outline: eating
Given there are <start> cucumbers
When I eat <eat> cucumbers
Then I should have <left> cucumbers

Examples:
| start | eat | left |
| 12 | 5 | 7 |
| 20 | 5 | 15 |

Data Table

1
2
3
4
5
Given the following users exist:
| name | email | twitter |
| Aslak | aslak@cucumber.io | @aslak_hellesoy |
| Julien | julien@cucumber.io | @jbpros |
| Matt | matt@cucumber.io | @mattwynne |

Steps Definition

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

@Given("there are {int} cucumbers")
public void thereAreCucumbers(int number){
xxx
}

@Then("I should see {string}")
public void thereAreCucumbers(string word){
xxx
}

@Given("the following users exist")
public void theFollowingUsersExist(DataTable dataTable){
xxx
}

参考

Gherkin Reference

Spring IOC & AOP

Overview

最近在复习Java相关的知识,Spring在几百年前系统的学过一些,当时也还没有养成记笔记的习惯,细节忘记的差不多了,也没有什么东西留下来。在bilibili上找了相对较新的基于Spring 5的一个教程,感觉还不错,跟着又重新学习了一遍,感觉还是很有收获的。目前看到AOP这边,后面还有Mybatis和事务的相关知识。

【狂神说Java】Spring5最新完整教程IDEA版通俗易懂

练习的相关代码放在https://github.com/bearfly1990/java-playground/tree/main/spring-core 中。

Read more

Kafka Learn - 01

Kafka

最近报名了公司的Kafka Training , 主要是自己看视频。今天主要记录一下使用到的命令和练习的Java Code,前期的概念有时间再总结下。从CLI和Java Code的这几节来说,主要练习了ProducerComsumer的使用,数据的推送和读取应该是一般人使用Kafka最基本和最常用的操作了吧。

Read more

Hadoop HDFS Operation

背景

之前搭好了 Hadoop 环境,但是在使用的过程中还是有一些问题,现在终于解决了,至少最基础的环境没有问题了。

基本环境

Hadoop-2.7.3 / Java7

四台机子如下,hadoop00mater, 其余为 slave

1
2
3
4
192.168.137.100 hadoop00
192.168.137.101 hadoop01
192.168.137.102 hadoop02
192.168.137.103 hadoop03
Read more

Setup Hadoop Cluster

背景

最近终于在虚拟上搭好了 Hadoop 的集群环境,记录一下。

资源准备

  • jdk-8u40-linux-x64.gz
  • hadoop-2.7.3.tar.gz
  • CentOS Linux release 7.4.1708 (Core)

四台机子如下,hadoop00 为mater, 其余为slave

1
2
3
4
192.168.137.100 hadoop00
192.168.137.101 hadoop01
192.168.137.102 hadoop02
192.168.137.103 hadoop03
Read more

Single Node Hadoop

背景

今天在阿里云机器上试着搭了一个单结点的 Hadoop, 记录一下过程。

资源准备

使用的 jdk 和 Hadoop 版本分别为:

  • jdk-8u40-linux-x64.gz
  • hadoop-2.7.3.tar.gz

系统是阿里云的 CentOS Linux release 7.4.1708 (Core)

Read more

Java Annotation

背景

开始回顾 Java 的一些基础知识,今天看了下注解。

像在 Spring 中,可以使用 xml 来配置类之间的关系与实例化,虽然结构清晰,但不是很方便。使用注解来让框架自己去识别你的意图,把配置放在了类定义中。

以下面上周写的简单 REST API 为例,通过使用 Spring MVC 相关注解就能配置方法与 HTTP Request 的对应。而使用 swagger 相关的注解,便很方便的生成对应的 API 文档。

而这些都是框架、第三方库通过反射得到注解的信息之后再得到的。

Read more