Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Practice of automatic functional testing

Shulou Source: shulou.com Published: 2022-06-03 05:27:26 11月24日 Update

My blog address: https://www.peretang.com/automated-functional-testing-in-action/

Development tools

IntelliJ IDEA / Eclipse

Apache Maven

Java JDK 8

Development framework

JUnit

Selenium WebDriver

Realization principle

Use Selenium WebDriver API to write functional test cases, use JUnit to be responsible for unit test basic configuration, and use Maven tools to help manage project dependencies

Demonstration code

Github

Operation steps

1. Create a Maven project

two。 Add Selenium dependency, because Selenium also depends on Junit, so JUnit dependency will be passed, and we don't have to declare our dependence on JUnit.

3. Download the corresponding WebDriver file, and we use the Chrome browser in our example, so we download the WebDriver file of Chrome [1]

4. Put the WebDriver file in the project path to facilitate the unified environment and use of the project.

5. Create a new test base class to set some common configurations and initialize the WebDriver object

6. Create a new test case, inherit the test base class, and then write the test logic

7. When you perform the test, you will see that Selenium automatically helps us open the Chrome browser and perform the operation according to the logic of our code

Referenc

[1]: Selenium wiki page

Tags: Tests projects files code tools browsers logic development browsing configuration functions functional tests units blogs principles fundamentals objects development tools articles frameworks Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Microsoft Apple macOS Redmi