Cross-platform testing framework-staf Introduction

Source: Internet
Author: User

Author: torrent

Staf, short for software testing automation framework, is an open-source, cross-platform, automated testing framework that supports multiple languages, as stated on its official website ( It focuses on the concept of Component reuse, service calling (such as process service, resource manage Service, logging service, and Monitoring Service) helps us save the effort of building a complex cross-platform automation framework, we only need to focus on our own automated implementation.

In short, staf is a platform that provides communication between different machines and operating systems. With its open-source advantages, staf has experienced development in recent years and has become more and more mature. It has the following features:
1. Easy to use, you can quickly build a cross-platform automated testing environment.
2. It is open-source and easy to expand. You can easily create a new service in staf.
3. Low environment requirements. Supports multiple platforms and multiple operating systems.
4. Supports multiple languages and can be called in Java, Linux Shell, C/C ++, Python, Perl, and other languages.

The following describes staf concepts in detail:


I. Principles
Suppose we have two machines A and B, and a is the master machine, as shown in:

It can be seen that both machine A and machine B have installed staf and configured a trust relationship with each other. Then, you can call the staf service on machine A to communicate with machine B. Such as transferring files and operating machine B. Therefore, the role of staf is to provide communication channels between machines and provide basic services based on this channel.

Ii. Concept of multi-layer Encapsulation


Based on the above introduction, we have learned that staf is a basic framework that can be reused and provide extensive support for various applications. Therefore, different packages are generated based on different applications. For example, if we construct a complex distributed test environment, we can use staf to distribute our test tasks to different test environments for execution, but if there are too many test tasks, in addition, new tasks are constantly added. Relying on staf alone is not conducive to the execution, management, and maintenance of test tasks. This introduces the concept of Stax. As shown in:

It can be seen that machine A has installed staf/Stax, so you can write a batch of staf service calls in XML format in a document, then Stax calls this document and translates it into staf service, which is passed to machine B for execution through staf.

In addition, in actual tests, some work is not achieved by staf. We often need some tools for automated testing. Such as robot. This requires an interface between the automated testing tool and the staf framework. This is what SAFS (software automation framework support) does. In SAFS, the key word-driven and data-driven concepts are introduced. Generally speaking, SAFS encapsulates common actions to provide support for third-party software. It also provides interfaces for massive data operations. For example:

Currently, the mature application interface based on SAFS is rrafs (rational robot automation framework support ). The following third-party software is now supported:

IBM Rational Robot

IBM Rational functional tester

SAFS image-based testing

Mercury Interactive winrunner

3. Services)


1. Service concept: staf builds an automation framework based on services. Services are reusable components of staf, and services are a set of functions. Staf is a background program. All components used in staf are services. staf provides a lightweight distribution mechanism to forward requests to these services.

Staf has two types of services: internal (Internal Service) and external (external service ). Internal services are integrated into stafproc to provide some key functions, such as data management and synchronization. External Services are dynamically loaded by stafproc and accessed through shared libraries.

2. Common staf services:

2.1 delay service: Internal Service, waiting for a specified time before the called program passes the returned value
2.2 diagnostics (DIAG) Service: Internal Service used to record or list diagnostic data
2.3 echo service: an internal service that provides functions similar to the ping service. The difference is that echo allows a specified character to be returned.
2.4 File System (FS) Service: an internal service that allows you to copy, delete, and view files.
2.5 Log Service: External Service for logging and viewing logs
2.6 monitor service: external service that provides operation monitoring
2.7 Ping service: Internal Service used to check whether remote staf is running
2.8 process service: Internal Service used to call external programs, such as Windows Command CMD/notepad.
2.9 Resource Pool (respool) Service: an external service that provides management or operations for resource pools, such as viewing, creating, and deleting resource pools.
2.10 semaphore (SEM) Service: internal service that provides mutex and event signal operations
2.11 zip service: external service that provides compression and decompression operations
Note: For more information, see

Appendix: Basic staf usage and simple configuration

1. Basic usage
Staf [-verbose] <endpoint> <service> <request>
-Verbose specifies that the output adopts the verbose mode. verbose is a data structure.
<Endpoint> IP address of the operation object. Specify the target staf system, which is parsed by stafproc to determine whether it is processed locally or sent to the remote staf system. Local can be written directly on the local machine.
<Service> specify the service to be called
<Request> parameters required to call the service
Staf return value: When the Service Processing ends, two types of data are returned. One is the return code of the service processing result, that is, whether the service is successful or failed, and the other is the specific data returned by the Service.
2. simple installation and configuration of staf

Assume that there are 2 machines, machine A is a Windows machine, IP address is, machine B is a Linux machine, IP address is

1. Download the installation package
Download the required installation package from the, including windows, Linux, Solaris, Mac and other different versions of the installation package. If JDK is not installed on the machine, you can download the installation package containing JDK.

2. Installation in Windows
2.1 On Windows, double-click the staf installation package and install it as prompted.
2.2 modify the staf. cfg file in the staf installation directory/staf/bin to configure the trust relationship between machines. Add the IP address of the Linux machine to the config file. As follows:

# Set Default local trust <br/> trust machine local: // Local Level 5 <br/> trust machine Level 5

2.3 restart stafproc
2.4 run the following command in cmd to confirm that staf has been correctly installed:
Staf local service list

3. Installation in Linux
Note: In some Linux versions, you must first install the C library, otherwise staf will not start. Refer:
In Linux, staf has two installation modes: Download the bin package directly and download the tar package for installation. Take the installation of the TAR package as an example:
3.1. Unzip the installation package:
Tar xzvf STAF331-linux.tar.gz
3.2 decompress the package and a staf folder appears.
By default, it will be installed under/usr/local/staf.
3.3 configure the environment variables and add the following code to the. bash_profile file under the username directory for running staf:
Path =/usr/local/staf/bin: $ PATH <br/> export path <br/> LD_LIBRARY_PATH =/usr/local/staf/lib <br/> export LD_LIBRARY_PATH <br/> classpath =/usr/local/staf /lib/jstaf. jar:/usr/local/staf/samples/demo/stafdemo. jar <br/> export classpath <br/> stafconvdir =/usr/local/staf/codePage <br/> export stafconvdir <br/> stafcodepage = latin_1 <br/> export stafcodepage <br/> nohup/usr/local/staf/bin/stafproc>/usr/local/staf/stafproc. out <br/>

3.4 modify the staf. cfg file under the/usr/local/staf/bin directory of staf to configure the trust relationship between machines. Add the IP address of the Windows Server to the config file. As follows:
# Set Default local trust <br/> trust machine local: // Local Level 5 <br/> trust machine Level 5

3.5 start stafproc
/Usr/local/staf/bin/stafproc &

3.6 confirm that staf has been correctly installed:
Staf local service list

4. test whether the staf configurations of machines A and B are successful.
Enter the following command on machine B. After the command is executed, machine B starts notepad:
Staf process start command notepad




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: 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.