Δοκιμή API ΧΡΗΣΙΜΟΠΟΙΩΝΤΑΣ QTP/UFT: Ολοκληρωμένο σεμινάριο
⚡ Έξυπνη Σύνοψη
API testing in QTP/UFT One validates a service directly, with no user interface involved. An API test is built as a flow of activities on a canvas, and checkpoints decide whether each response passes.
Before testing an API, we need to know what an API is. An API (Application Programming Interface) is a collection of software functions and procedures that can be executed by other software applications.
Τι είναι η δοκιμή API;
Δοκιμή API είναι ένα δοκιμές λογισμικού method for validating Application Programming Interfaces (APIs). The goal of API testing is to test the API in terms of functionality, reliability, security and performance. In API testing, software is used to send inputs to the API, and the output is recorded in order to test the API.
So API Testing is:
- Δοκιμή χωρίς GUI
- Programmatically simulating data or control-flow scenarios.
- Επικεντρωνομαι σε λειτουργικότητα, not on behavior or customer experience.
The diagram below places API testing between the client that calls the service and the data it reaches.
Γιατί είναι σημαντική η δοκιμή API;
API Testing has four significant advantages
1. Η δοκιμή API είναι η τάση
As the following figure shows, API testing has grown very fast over the last ten years. It has become far more popular than other testing types.
2. Χρόνος αποδοτικός
With API Testing we can use parallel execution to reduce test execution time. You can save up to 5 times compared to other testing types.
3. Γλωσσικό ανεξάρτητο
Στη δοκιμή API, τα δεδομένα ανταλλάσσονται μέσω XML or JSON, so any language can be used to test the response. For example, if you have a service whose response is in JSON format, you can easily parse the data with Java, C# or any other language.
4. Εύκολη ενσωμάτωση GUI
Επειδή UFT One holds GUI tests and API tests in the same solution, an API call can set up data for a user interface test and both kinds of test report into the same run results. That keeps a service check and the screen that consumes it in one project instead of two toolchains.
Δοκιμή API με UFT (Ενοποιημένες Λειτουργικές Δοκιμές)
There are many tools available, both open-source and commercial. UFT is a strong choice for executing API tests, because the flow is built visually and the configuration is kept in one properties pane.
Η τελευταία έκδοση του QTP, called HP Unified Λειτουργική δοκιμή (UFT), είναι ένας συνδυασμός HP QTP (a GUI testing tool) and HP Service Test (an API testing tool). UFT υποστηρίζει τον Ιστό, Java, .NET, Oracle, Siebel, web services and many other major languages and platforms that older versions did not support.
⚠️ Ονομασία προϊόντος: the tool described here as HP UFT is now sold as OpenText Λειτουργικές δοκιμές (UFT Ενας), having passed from HP to Micro Focus and then to OpenText. The screens below come from the HP-era release, so menu wording differs from current builds, but the API test flow, activities and checkpoints work the same way.
Τύπος υποστήριξης δοκιμών API από HP UFT
- υπηρεσία Web
- ΠΕΡΙΦΕΡΕΙΑ
- Αντικειμενοστρεφής γλώσσα
- βάση δεδομένων
- Ιδιόκτητο API
Ξεκινήστε την πρώτη σας δοκιμή API με QTP
Σε αυτήν τη δοκιμή API σε UFT tutorial, we will cover UFT API testing examples. We are going to test the Graph API of Facebook. We will test the API as the Δοκιμαστική θήκη παρακάτω
- Αποκτήστε ένα προφίλ του συγκεκριμένου χρήστη στο Facebook.
- Verify that the profile is as per expectation
Ακολουθεί ένα βήμα για τη δημιουργία μιας δοκιμαστικής ροής για αυτό το API.
⚠️ About this example: Facebook retired Graph API v2.3 years ago and the access token shown below has long since expired, so the exact call no longer returns data. The original request is kept unchanged as the worked example; point the same steps at any current REST endpoint to follow along.
Βήμα 1) Ανοίξτε HP UFT και δημιουργήστε νέο έργο API Testing
- Επιλέξτε Έναρξη > (Όλα) Προγράμματα > Λογισμικό HP > Ενοποιημένος έλεγχος λειτουργίας HP > Ενοποιημένος έλεγχος λειτουργίας. In current releases this is simply the UFT Ένας συντομώτερος δρόμος.
- Πατήστε Αρχείο > Νέο > Δοκιμή. Επιλέξτε το Δοκιμή API τύπος
- When a dialog box opens, input the name of the API test: API_Facebook, and select a location to save this project. Click δημιουργώ to create the API test project.
Step 2) Adding HTTP Request to Test Flow
We will use the HTTP Request to make a request to the Facebook API.
Step 3) Configure and pass parameters into an HTTP request
- Κάντε δεξί κλικ στο Αίτημα HTTP object to edit it.
- In the Properties part, enter the URL
https://graph.facebook.com/v2.3/me?access_token=CAACEdEose0cBANJsDnbZC92mNAghaM6xxZCZBZAvKlMXS98VYvKy%20OlrfAdsUWR8x5aw9Kqc0grscs9zb9IYED4VC3FwapIZBj%20dsuxy%20HdLcff38gYUBFNeRQlH%20fN7eXKoVZBNl0bR233ZAZCw8fLF1QLh98ry2ZBeYBhXLabtTDkFPZA1IqhaMG0mQp30zO1%20QxQ19nVCxZArJA6XRoB1o5FMepII5cn3DgbBmTgZD
- You can also pass a parameter into the API by setting values in the Κεφαλίδα αιτήματος πλέγμα.
Χρησιμοποιήστε το Graph API Explorer of Facebook to obtain the value of access_token.
- Ρυθμίστε το Μέθοδος HTTP προς την ΠΑΡΤΕ.
- Διαμορφώστε Σημεία ελέγχου του Αίτημα HTTP. Set the Status code to 200 in the Checkpoints part. Checkpoints let you see whether the action was successful without having to check the result manually, and the pass or fail verdict of the test is determined by them. A status code of 200 means the test case has passed.
Βήμα 4) Εκτελέστε τη δοκιμή
Κάντε κλικ στο τρέξιμο κουμπί ή πατήστε F5, to open the Run Test dialog box. Click τρέξιμο to compile and run the test.
Step 5) View the result
Ανοίγει το πρόγραμμα προβολής αποτελεσμάτων εκτέλεσης. Σε αυτήν τη δοκιμή API χρησιμοποιώντας UFT example, a failed test case is reported like the following figure.
When the test case passes, the result is reported as below.
Your first API test in UFT is now complete.
Πού να πάω από εδώ
Now that you have learned to create a test with an API test in UFT, you can create your own test for your GUI-less application. Adding a οδοφράγματος per response and grouping calls into συναλλαγές are the usual next steps.

















