To make full use of LoadRunner's scenario control and analyzer, we can better control the Script Loading Process and display more intuitive and effective scenario analysis charts. This article focuses on how LoadRunner calls Java testing.CodeTo complete the stress test.
When we perform stress tests on some servers, we usually inadvertently want a client to complete the server call example, so that we can directly record it through LoadRunner, it is really convenient for testers. However, the developer
If the tester does not have so much time to serve the tester, it may be a tragedy. He can only try to call the interface to complete the stress test, in this way, you need to have some code skills. Of course, after calling the interface code, make sure that
LoadRunner can record correctly, which is indeed a little troublesome. In many cases, the pressure on our interfaces may not be displayed through the client, so we can only do this in the form of pure code on the server, either multithreading or repeated calls, but for testing
The collection of results is not so convenient. Therefore, we still need to use the advantages of some tools and take advantage of them for our use. LoadRunner's chart analysis is the best of all tools, it also supports calling interfaces such as Java code and C ++.
Java is used as an example.
Generally, in a project file, we want to call a Java file, but this Java code always calls each other with other code, so I need to introduce a lot of Java packages or some jar packages. The following is a detailed description through this practice.
Next, let's take a closer look at LoadRunner's steps to call Java code. Here, the environment is loadrunner11 and jdk1.6. The project development is Java + flex, and the test of a unified logon interface is completed. The procedure is as follows:
1. Package the Java project file into the jar format. For example, if the project here is logindemo, package the JAR file and then use logindemo. Jar
2. Find the lib directory under the Java project file. Basically, the Lib file is a jar package. This is the jar package called by the project file.
3. Enable LoadRunner to create a Java vuser script. Run the script first to check whether the script is correctly executed and save the file.
4. Set logindemo. jar and Lib jar files are all imported to LoadRunner's classpath. Ensure that the JDK file is imported to LR and the JDK file is set at runtime in vuser -- In LR, as shown in;
5. After completing the preceding operations, we can introduce the call in Java in the vuser script.ProgramWhen I started using the import method, I found it strange that it was successful for the first time, but the backend always reported that the package could not be found and paused for a long time, so we introduced the package method and found that it was still true. Then we started running and found that it was very useful, and the program call was indeed OK.
Note: There are actually no special operations here, mainly for the jar package calling method, you may need to pay attention to the following points:
1. When a jar package is introduced, for example, the method of introducing the jar folder above is not feasible. This is a suspect, so you can only choose to import all the jar packages together.
2. When a Java package file is introduced to a vuser, the import method does not work occasionally. Therefore, it is absolutely feasible to select the package method.
3. Some errors may occur during running after the vuser introduces the Java package, which are basically jar files. If you find the classpath of LoadRunner, it will be okay, in addition, JDK must be first imported. Otherwise, the system will directly prompt that the process is terminated,
Cannot run Java files
4. LoadRunner has a variety of methods to introduce java files. Here, we call the jar package in the most common way, which is also the most convenient. Of course, you can also copy the class file compiled by Java to
In classes, you must copy all the Java class package folders to execute. This method takes the calling time, and the jar package to be called must be imported under classpath.
As for the implementation of Java business logic, it can be implemented in Java, and then the vuser can directly call the method interface, but it can also be done in vuser. Then, you can set the number of virtual users in the scenario to test the scenario. Then, the score is obtained based on the test results.
Graph analysis, which is basically the same as other recording testing methods.