Behavior Driven: Cucumber + Selenium + Java (a) - environmental structures

1.1 What is behavior-driven testing

Speaking of driving behavior, I believe many people have heard of.

Behavior-Driven Development -BDD (Behavior Driven Development) is a software development concept was born in 2003. The key idea is to get a clear understanding of the expected behavior of the software through discussions with stakeholders, it is readable by non-programmers to write test cases with natural language extended test-driven development approach. BDD provides a versatile, simple, structured description language, which can be both in English can also be other local languages, he can easily make by project members and business stakeholders very smooth communication needs, these stakeholders can not understand any programming language and technical details. The advantage of this concept is obvious that our entire software development process more understandable and easier to close to user needs, which can get very good feedback and interaction effects, and reduced the number of intermediate links (such as the implementation of the system details to explain to the user).

The so-called behavior-driven testing is further extended to apply the concept of BDD's, deals with a behavior-driven philosophy we use in the testing process, our test cases using the expression language structured organized. So our testing, especially test cases can be easier for all aspects of the team and the customers understand. Under such conditions, we can say that our test case almost entirely on behalf of the user's position, but with such a testing process to validate our development process, it can be regarded as 'test-driven development' reflects a preliminary form.

1.2 What is the Cucumber

Cucumber is an open source tool for behavior-driven development support. More precisely, Cucumber can be defined as a testing framework, in plain English (or other natural language) is driven by a text, we can use it as a document, automated testing and development assistance. We will Cucumber and Selenium framework combines automated testing, we can let our automated process reflects the 'driver behavior' characteristics.

1.3 build Cucumber environment

If we use Maven to build cucumber environment will be relatively very simple, just add the corresponding dependencies in the pom file can make maven project is configured to automatically crawl and we need the jar package.

For learning purposes, we do not use maven, but to manually configure these dependencies.

To build Cucumber environment, we need the following things:

- JDK:推荐使用1.8
- 集成开发环境:这里我们使用eclipse
- eclipse的cucumber插件
- cucumber框架所需的jar包
- selenium的相应jar包

1.3.1 JDK installation

JDK download and install and configure the environment variables large number of online tutorials, this will not repeat.

1.3.2 eclipse installation

eclipse installation is very simple, this will not repeat.

1.3.3 cucumber plug-in installation

By eclipse menu, Help-> Install New Software Plug into the installation. Add installation address http://mrpotes.github.com/cukes-jvm-eclipse-plugin/update-site , Cucumber JVM plug-in will check and install.

  

1.3.4 Download selenium and cucumber required jar package
  

We need these jar package is shown on the map, they can be downloaded in Mavenrepository to: https://mvnrepository.com/ .

Search these jar package, you will be able to download the appropriate file, such as Core-1.2.2.jar-Cucumber: https://mvnrepository.com/artifact/info.cukes/cucumber-core/1.2.2

  

You will be able to obtain the corresponding jar package through the download link in the red box, the other jar package the same way.

  

Just great all the jar packages later, we create the eclipse in a java project, under the new project lib folder and copy all of the above jar package into a folder. Then, right-click the project and select Build Path -> Config Build Path.

Libraries interface by selecting Add Library, to add in these jar package:

  

After the addition, and click OK. So far, our Cucumber + Selenium + Java environment has been set up is complete.

All resources used in this article can get in the network disk address:
link: https://pan.baidu.com/s/17BGbbo1nYLLe6dmp3KJYIA
extraction code: v9tf

Guess you like

Origin www.cnblogs.com/dayu2019/p/11539883.html