Kaddy10
Kaddy10

Reputation: 21

Robot tests calling another robot file

Is it possible to call a robot framework file from another robot framework file. Can some one give examples of it

Requirement

We have some tests which are of repetitive nature. The idea is to have these tests present in a Robot file which can be called into the main robot tests file. This will allow us to keep adding to the list of repetitive tests and all the new / old tests will be available for the main tests.

Any examples will help. Thanks.

-KK

Upvotes: 1

Views: 6119

Answers (3)

Upkar Singh
Upkar Singh

Reputation: 19

just import the another robot as a Resource

Settings:

Library    PythonLibrary.py
Resource   <Folder_Name>/Example.robot

Upvotes: 1

Ansu
Ansu

Reputation: 69

Yeah. Just declare the file that you wish to call in Settings section of your code as specified below.

Resource ../common/Resource_Apps.robot

Now you can use or call all the keywords written in this resource file.

Upvotes: 2

Bryan Oakley
Bryan Oakley

Reputation: 386030

Tests (or Test cases) are not reusable components in robot framework. Tests exist to perform verifications. Once those verifications have been made, there's no point in running the test again in the same test run.

Even though tests can't call other tests, they can call user keywords, which is the foundation of robot framework. If you have bits of functionality that you want to be reusable, you put that functionality in keywords, and then you can use those keywords in as many tests as you want.

For example, lets say that you need to send a signal to a device and check for a light to come on. Instead of writing a test that does this, and then repeating the test over and over, you create a keyword that sends the signal, and a keyword that verifies the light is on, and then call these keywords from multiple tests (or one data-driven test).

Upvotes: 2

Related Questions