简体   繁体   English

Maven测试Web应用程序的响应时间?

[英]Maven tests for web application response time?

I have a webapp that recently started to show slowness even when the homepage is loaded in the browser. 我有一个Web应用程序,即使将主页加载到浏览器中,它最近也开始显示运行缓慢。

Since I'm using Maven to manage it, I thought I could add some simple test to check the load time of the homepage or of a specific page — I never wrote one, so I don't know if this is feasible. 由于我使用Maven进行管理,因此我认为我可以添加一些简单的测试来检查主页或特定页面的加载时间-我从未编写过代码,所以我不知道这是否可行。

I don't need anything fancy, just something that says: "if load time is greater than X seconds, signal it" (ie stop the build process); 我不需要任何花哨的东西,只是说:“如果加载时间大于X秒,则发出信号”(即停止构建过程); that way I will be alerted that a recent change is making things worse, so I do not discover them too late. 这样一来,我会被告知最近的变化使情况变得更糟,因此我不会太晚发现它们。

Is this even possible with the current available tools and / or plugins? 使用当前可用的工具和/或插件,这是否有可能? What should I look for? 我应该找什么?

A CI server is not available at this time, so I can only rely on anything that can be automated by Maven. 目前没有CI服务器,因此我只能依靠Maven可以自动化的任何东西。

Beside suggestions about what tool to use to perform the tests, I need help making the test run automatically in my Maven setup (ie they should run when I call mvn clean package or some other goal and stop the build if a problem is detected). 除了关于使用哪种工具进行测试的建议之外,我还需要帮助使测试在我的Maven设置中自动运行(即,当我调用mvn clean package或其他目标时,它们应该运行,如果检测到问题,则停止构建)。

You can use Selenium to perform web tests, configuring it to timeout if some part of the web page is not loaded in the specified time 您可以使用Selenium执行Web测试,如果在指定时间内未加载网页的某些部分,则将其配置为超时

....
WebDriverWait wait = new WebDriverWait(webDriver, 5);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("myxpath")));
....

You can also use JMeter to perform load testing. 您也可以使用JMeter进行负载测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM