Usually, verifying an HTTP code is not enough. In the previous sample, I managed to send a GET request and verify the response’s HTTP code. Sending API requests and verifying responses In a nutshell, the VU module is a load test. It is the heart of every test, and depending on the init module, the code therein is executed several times. The VU (virtual user) module contains all of the code that is written inside the default function() module.All functions that clean up our testing, such as delete user, remove user data, and so on, are candidates for this method. Teardown: The teardown module, like setup, will only execute once - at the end of the test.A basic create a user or produce data method is an excellent choice for this module. Setup: The setup module is utilized as a one-time test setup, and the code within will only run once at the start of the test.The test scenarios, global variables like endpoint address, and everything else on the global level is specified in the “init” module. Initialization: Code written outside of the setup(), default function(), and teardown() methods is referred to as initialization.Open up Visual Studio Code and add a new JavaScript file with content in the content below. I chose to give k6 one more shot because it seems to be a useful piece of software.īuild a k6 load testing script from scratch Have I hit a snag?Īs I hit a turning point, I needed to decide whether to move on with k6 or go back to the good-old Apache JMeter distributed test setup. Fortunately, there is a way to change the auto-generated k6 script and make magic happen, but with over a thousand lines of auto-generated code on my end, that could take days. Before running the k6 script, dynamic variables and most functions from pre-test and post-test scripts require maintenance or perhaps creation from scratch. The majority of super-cool features that are used in the Postman collection are not supported in k6. A deeper analysis showed that, in most cases, we cannot simply convert a Postman script and run it as-is. K6 run k6-script.js Something went wrong, what now?Īfter reviewing the results, it was clear that something wasn’t quite right. For a Windows user like myself, installation is super easy - download, next, next, and finish.Īfter k6 installation, open the auto-generated script in your favorite code editor (my personal pick is Visual Studio Code), bring up a terminal window, run the command below, and check the results. To install it, just follow the instructions for your system. K6 tool supports various platforms, including Windows, Linux, macOS, and docker. Should you want to do some fine-tuning of your tests, like adding data or changing environment variables inside your code, please refer to the official documentation: postman-to-k6 README. postman-to-k6 test-api.json -e env.json -o k6-script.js Step 3: Convert your exported Postman collection to k6 scriptĪssuming that the exported collection is named “ test-api.json” and the environment variables “ env.json”, run the following command to convert it to a k6 script. To convert the Postman collection, export it as well as any variables (if they exist). Step 2: Export your Postman collection end environment variables Install it by typing the below command into the terminal. The postman-to-k6 tool helps to convert your Postman collection to k6 JavaScript code. Note: In case, you get the unknown command message, please install the node from You should get info about the installed version here. Open the command prompt and type in node –v. I was truly shocked at this chance to once again use my super-fancy-do-it-all-with-a-single-click Postman collection! How to make it happen?įirst, check if node.js is installed on the machine. K6: Create tests faster with our test builder, recorder, or converters (JMeter, Postman, Swagger). Out of nowhere, a simple open-source load testing tool caught my attention - k6. Once again, I resorted to my Google search skills determined to find a quick, clean solution. However, without a JMeter distributed testing feature set in place, testing on a single machine would be mission impossible. It is a functional open-source application with a lot of plugins and a simple interface for creating and running load tests. The very first tool that crossed my mind was the old faithful Apache JMeter. There was no need to capture metrics, create fancy graphs, or anything like that, but rather to examine if we can use the app while it is under a constant load. ![]() ![]() Recently, I received just such a request to test an app’s responsiveness with a constant load of several thousand concurrent users. Working as a Quality Assurance Engineer means that you can expect a last-minute testing request at any moment.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |