Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Jmeter calls custom jar package

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

one。 Scene

In the process of testing, you may need to call a third-party jar package to generate test data or use java tool classes to implement business scenarios. The common practice is to manually call the jar package, and then assign these values to a parameter in jmeter to meet the business testing requirements. Jmete has the function to call the jar package, which can be used to embed calls to the jar package.

two。 Customize the jar package

Using Eclipse or IntelliJ IDEA, depending on your personal preferences, IntelliJ IDEA seems to be better. Write a very simple java.

Public class Test {

Public static String stringFormat (String s) {

Return s + "Jmeter Wechat official account: the growth of Test Engineering,"

}

}

Use IntelliJ-> File- > project structure

After the above configuration is completed, you can build jar the package.

three。 Call custom jar or third-party tool classes in Jmeter

There are generally two ways

First kind

Place the package directly in the extension package directory of jmeter:

% jmeter_home%/lib/ext

The second (recommended)

In the add directory or jar to classpath of the test plan, import the jar package.

Then BeanShell can directly use import's own class, just like in java.

Add a sampler to jmeter

Write java code under beanshell sampler to call the jar package

The only method stringFormat in the test class of the import custom jar package, return returns the result.

Add listener-> View the result tree and check the call status

The function of calling custom jar package is that jmeter opens a wider door for us. Imagine whether many complex business scenarios in the project can be encapsulated by java. Jmeter is only responsible for calling the jar package and letting jmeter do more focused things.

Today's recommended reading articles are recommended

Why do interface testing?

JMeter database operation

Jmeter Interface Test-regular expression

JMeter returns garbled code in Chinese

Jmeter interface testing-parameterization

JMeter Interface testing-Basics

Test-impression

Add Wechat to the consulting work

scan a QR code

Welcome self-recommendation and recommendation, need Wechat to push resume!

Please poke the QR code below to learn more.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report