How to use the robot framework

Source: Internet
Author: User

1. Background code:

Directory structure:

Test code: arithmetic.py

2. Start writing Use cases

Create a new TXT file directly on eclipse, or write a use case through ride.

(1). First create a new directory on Eclipse testcase, file test. txt

(2) Editing use cases in test. txt

The first part: Settings

Mainly used for the introduction of the resources used;

or the initialization or destruction of test case test sets (which will be explained in detail later)

Note: (1) The above uses a relative path (2). /indicates the top level of the current directory (3) Liabrary to have at least two spaces with the following path, or it will be an error

The second part: Variabls (Here you can set some constants, of course you do not set here also can, in each use case separately set can also)

The constant name is enclosed in ${}, followed by its value

Note: The constant name and value are also separated by two and more than two spaces, otherwise you cannot save

Part III: Testcase

The line written by Shelf is the name of the use case, such as "Test division: Divisor is not 0 o'clock, can be calculated successfully" is the name of a use case

The following spaces are the steps to begin writing as a use case:

The first line assigns a value to variable B, where set variable is the built-in library of the robot framework

The second line is to execute our own test code, Divide calculate is a keyword that corresponds to the Divide_calculate () method in arithmetic.py. It is important to note that this method must be in a class (as divide_calculate here is in the arithmetic class), if the py file is not a class file, such a keyword will not work. (Note that there must be only one space between the words of the keyword and the word, such as divide Calculate, there can be only one space between the two words, but there must be two and more than two spaces between the keyword and the other variables or constants, such as the keyword divide Calculate and the variable ${ A} must have more than two spaces)

The third line compares the actual values to the expected value

3. Perform the test

(1). Click the Ride icon to enter the ride interface

(2). Importing Test Cases

Click File-open Directory, find your directory, click OK

The use case was imported.

At this point you click on the test, on the right side of the text edit can see your test case, here can also edit

(3) Executing test Cases

Tick the test case you want on the right

Click Run

The results above are not very clear.

You can also click on the report or log above

Report

To find out more information, click Log:

Expand the test details for the view test case: There will be print information at every step.

The above is the basic use of the robot framework, read is not so easy AH

How to use the robot framework

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.