Maven实现Web应用集成测试自动化 -- 测试自动化(WebTest Maven Plugin)

使用Java+Maven+TestNG进行自动化测试 写作背景:有点Java基础的功能测试人员(点点点工程师),所在项目有"去QE"的趋势,所以自己要多点亮其他技能,让路子走宽点。简单说一下去QE:项目测试不再有专职的测试工程师来做,而是由开发工程师自己来进行。遵循“谁开发、谁测试、谁上线、谁On call”的原则。 阅读详情

最近在appfuse看到使用webtest-maven-plugin实现Web应用的集成测试,研究了下,感觉非常不错,对于Web应用自动构建非常有帮助,在性能测试之前可以保证Web应用的基本功能工作正常,分享给大家。

WetTest工作原理

它是基于Ant来运行的Web页面的测试工具。通过运行不同的target,测试页面上面提供的所有功能。它的工作原理是运用比较出名的HtmlUnit来实现对一个页面功能的测试。它的工作流程就是模拟一个浏览器的事件(页面提供的功能:可以调用一个Url,可以点击一个button,label等,可以为页面上的元素赋值),然后通过抓取返回的页面上的Title或者是element的值来校验是否返回预期的结果。

WetTest与Maven的集成配置

Maven的配置

在Web应用的pom.xml中引入webtest-maven-plugin,定义集成测试阶段执行测试,验证阶段执行结果验证,系统集成测试之后生成报告。同时指定Web应用的地址,测试用例所在文件,生成文件所在路径,日志级别以及遇到错误的时候采取的策略。这样在Maven构建阶段就会自动执行WebTest的测试用例。具体配置如下:

在build节点加入webtest插件  (插件具体参数参考)
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>webtest-maven-plugin</artifactId>
                        <version>1.0.0</version>
                        <executions>
                            <execution>
                                <id>webtest-test</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>webtest-verify</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>verify-result</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>webtest-report-html</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <host>${project.cargo.host}</host>
                            <port>${project.cargo.port}</port>
                            <sourcedirectory>src/test/resources</sourcedirectory>
                            <sourcefile>web-tests.xml</sourcefile>
                            <target>${project.webtest.target}</target>
                            <basepath>${project.build.finalName}</basepath>
                            <resultpath>target/webtest/webtest-results</resultpath>
                            <resultpath>target/webtest/webtest-results</resultpath>
                            <haltonfailure>false</haltonfailure>
                            <haltonerror>false</haltonerror>
<pre name="code" class="html">                            <autorefresh>true</autofresh>
                            <loglevel>fatal</loglevel>
                        </configuration>
                    </plugin>
 
 
WebTest用例文件(Web-tests.xml)配置
 
 
 
?xml version="1.0" encoding="UTF-8"?>
<!-- 导入 config & login xmlf -->
<!DOCTYPE project [ 
    <!ENTITY config SYSTEM "./config.xmlf"> 
    <!ENTITY login SYSTEM "./login.xmlf">
]>

<!-- 定义默认跑的target -->

<project basedir="." default="run-all-tests">       

    <!-- 在ant中引入webtest标签 -->

    <taskdef resource="webtestTaskdefs.properties" /> 
    
    <!-- web系统很多都是多语言的,做页面验证的时候也需要多语言支持, 第二个找不到其他语言时候的默认语言 --> 
    <property file="../../../target/classes/ApplicationResources_${user.language}.properties"/> 
    <property file="../../../target/classes/ApplicationResources.properties"/> 
    <!-- 定义 runs all targets,依赖系统中各个功能模块,登陆,登出,用户操作--> 
    <target name="run-all-tests" depends="Login,Logout,UserTests" 
         description="Call and executes all test cases (targets)"/> 
    <!-- 定义runs user-related tests,RUD,系统不存在用户Create功能 --> 
    <target name="UserTests" depends="EditUser,SearchUser,SaveUser" 
        description="Call and executes all user test cases (targets)"> 
     <echo>Successfully ran all User UI tests!</echo> 
    </target> 
    <!-- 登陆测试,Login to the application --> 
    <target name="Login" description="Runs login test and verifies Home's Title">           
        <!-- 定义登陆测试的webtest具体内容 -->            
        <webtest name="login"> 

            <!-- 先执行webtest配置 -->

            &config;                                       
            <!-- 具体测试步骤,来自login.xml -->            
            <steps> &login; </steps> 
        </webtest> 
     </target> 
     <!-- Logout of the application --> 
     <target name="Logout" description="Runs logout test and verifies Login's Title"> 
         <webtest name="logout"> 
             &config; 
             <steps> 
                 &login; 
                 <invoke description="get Logout Page" url="/j_security_logout"/> 
                 <verifytitle description="we should see the login title" text=".*${<span style="font-size:14px;">login.service</span>}.*" regex="true"/> 
             </steps> 
          </webtest> 
     </target> 
     <!-- Verify the edit user screen displays without errors --> 
     <target name="EditUser" description="Tests selecting the 'Edit Profile' forward"> 
          <webtest name="editUser"> 
               &config; 
               <steps> 
                   &login; 
                   <invoke description="click Edit Profile button" url="/userInfo/save.action"/> 
                   <verifytitle description="we should see the user profile title" text=".*${userProfile.title}.*" regex="true"/>
               </steps> 
           </webtest> 
     </target>
  </project>
由于一般的测试都离不开这个Login界面,所以把Login的target抽出了,还有连接服务器的配置config任务也可以抽出来放成两个 单独的文件了。login.xmlf:登陆页面具体操作
<invoke description="get Login Page" url="/"/>
<verifytitle description="we should see the login title" text=".*${system}.*" regex="true"/>
<setinputfield description="set user name" name="j_username" value="admin"/>
<setinputfield description="set password" name="j_password" value="password"/>
<clickbutton label="${login.submit}" description="Click the submit button"/>
<verifytext description="Home Page follows if login ok" text=".*${welcome}.*" regex="true"/>
config.xmlf:webtest的配置,使用webtest-maven-plugin中configuration值做为输入参数一部分
<config host="${host}" port="${port}" protocol="http"
    basepath="${basepath}" resultpath="${resultpath}" saveresponse="true"
    resultfile="web-tests-result.xml" haltonfailure="${haltonfailure}"
    haltonerror="${haltonerror}" autorefresh="${autorefresh}">
    <header name="Accept-Language" value="${user.language}"/>
    <option name="ThrowExceptionOnScriptError" value="true"/>
</config>

配置web-tests.xml的细节可以看:官方manual
小心地雷:
1. webtest-maven-plugin很久木有更新了,里面依赖的htmlunit的版本太旧了,之前我直接使用plugin自带的依赖htmlunit2.8直接导致测试挂死,jstack dump出来的线程是running状态,把log改成debug也看不出来为什么挂死,幸好看到appfuse里面说更新了htmlunit的版本解决和jquery的兼容性问题,这是个很大的坑,一定要去htmlunit看看它兼容什么js,或者在appfuse里面看也行。
2. 在测试的时候遇到了以下异常,当时以为是语法写错了,研究了一阵子才发现是resource file中没有定义login.title,定义被改成了login.service,这里不是语法问题。。。具体复杂配置语法参考java reg官方文档
java.util.regex.PatternSyntaxException: Illegal repetition near index 2
.*${login.title}.*
3. 最开始没有把autorefresh打开,结果login page spring security3默认是回给客户端一个自刷新页面,导致测试失败


下篇:Maven实现Web应用集成测试自动化 -- 部署自动化(Cargo Maven Plugin)

部署安装WebPageTest私有实例_linux webpagetest 部署安装,WebPageTest 原本是由AOL开发内部使用的工具,后来在Google Code上开源, 是一款非常优秀的网页前端性能测试工具。 立即下载

相关推荐

Maven简易教程,maven 自动构件,自动测试,自动发布

maven 自动构件,自动测试,自动发布

Maven学习(四)- 使用Maven构建Web项目-测试

在上一篇博客里,我们使用Maven构建了一个Web项目,我们在这里写一个简单的Servlet,测试一下。 1.在src/main/java下,新建一个Servlet package com.deppon.text01.action; import java.io.IOException; import javax.servlet.ServletException; import java

什么是江湖? 1万+

教程 | VeriStand硬件在环仿真测试第一章

这篇是系列文章的第一章,满满的都是干货,感兴趣的话欢迎一起交流探讨。

HUASUITECH的博客 1万+

Maven test 生成Spring Boot 接口集成测试的中文测试报告

mvn test 生成中文测试报告

zhou_Tian的博客 970

DESeq2差异分析结果不会看?用这个R脚本5分钟生成发表级火山图和热图

本文详细介绍了如何使用R语言快速可视化DESeq2差异分析结果,5分钟内生成可直接用于论文发表的火山图和热图。通过解析DESeq2数据结构、展示ggplot2和EnhancedVolcano包的绘图技巧,以及pheatmap包的热图定制方法,帮助研究者高效呈现差异表达基因分析结果。

weixin_30326515的博客 340

基于ESP32的摩托车蓝牙对讲系统开发实践

蓝牙音频传输技术在现代通信中扮演着重要角色,其核心原理是通过无线射频实现数字音频信号的双向传输。在工程实践中,蓝牙HFP协议常用于语音通信场景,而ESP32等嵌入式平台因其低成本和高集成度成为DIY项目的理想选择。本项目通过ESP32-WROOM-32D开发板结合PCM5102 DAC和INMP441数字麦克风等模块,构建了一套摩托车骑行专用的蓝牙对讲系统。该系统特别针对高速移动环境下的风噪抑制和连接稳定性进行了优化,采用数字信号处理技术实现实时降噪,并通过I2S接口确保音频质量。这种方案不仅成本控制在30

weixin_33239721的博客 414

聊 一聊 maven 测试相关的插件

本文主要对 maven 的测试执行和测试报告产生对应的两个插件进行了介绍,希望通过本文,读者可以对这块有个基本的认识,以便于在日常的开发工作中,能够应对类似的问题和场景。

m0_71744960的博客 1865

基于VS2012 C#调用bartender自动打印条形码

GitHub:https://github.com/sanjaywu/BarcodePrintTool 一、在引用添加Interop.BarTender.dll 1、在资源解决方案的引用这里,右击选择“添加引用”: 2、按照如下步骤添加Interop.BarTender.dll引用: 3、添加完成 二、使用bartender工具设置打印模板 1、页面大小设置: 2、条码设置: 三、代码...

Sanjay_Wu的博客 5956

测试开发基础 mvn test | 利用 Maven Surefire Plugin 做测试用例基础执行管理

Sonarqube scanner使用,需要先安装好环境及配置文件。 在测试工作场景中,经常会遇到下面的问题: 1、执行自动化测试用例的时候,只想指定某个测试类,或者某个方法,又或者某一类用例等,怎么办? 2、想要和 Jenkins 一起进行持续集成,可是用例又不可能在 IDE 里面执行,怎么办? 这个时候就需要 Maven 登场了,利用 Maven 的Maven-Surefire-Plugin插件可以帮助我们完成上述的目标!它可以通过命令行的形式来管理我们要执行的用例。 Maven 3.x

软件测试小迷糊 1158

打通Creo与Matlab的桥梁:Simscape Multibody Link插件安装与配置全攻略

本文详细介绍了Simscape Multibody Link插件的安装与配置全流程,旨在帮助机械工程师和开发者打通Creo与Matlab/Simulink之间的桥梁,实现CAD模型到多体动力学仿真的高效转换。文章重点解析了版本兼容性、管理员权限、注册文件配置等关键步骤与常见故障排查方法,助力用户快速建立设计与仿真一体化工作流。

rrr55的博客 634

【MFRC522】STM32与MFRC522的SPI通信优化及常见问题解析

本文深入解析了STM32与MFRC522进行SPI通信的优化方法与常见问题。从基础的硬件连接到SPI时序优化,再到关键的寄存器配置(如RFCfgReg设为0x4F以提升读卡稳定性),文章提供了详细的调试技巧和实战排坑指南,帮助开发者实现稳定高效的IC读卡应用。

yhn45678901的博客 841

Maven实现Web应用集成测试自动化 -- 部署自动化(WebTest Maven Plugin)

通过codehaus的cargo结合Maven实现Web应用集成测试自动化步骤中的部署自动化

cloud的技术积累 1956

(3dnr)多帧视频图像去噪 (一)

视频图像去噪主要利用相邻帧间内容相似性,通过时域帧平均降低随机噪声。为避免运动物体产生"拖尾"现象,可采用运动自适应或运动补偿时域滤波方法。前者根据运动强度动态调整滤波系数,后者通过运动补偿使参考帧更接近当前帧。运动补偿方法虽能更好处理运动区域,但计算复杂度高且对快速运动场景效果有限。相比之下,运动自适应方法在实时视频处理中更具优势,能平衡去噪效果与硬件资源消耗。两种方法可根据场景动态切换以获得最佳去噪效果。

大熊 1871

Maven实现Web应用集成測试自己主动化 -- 測试自己主动化(WebTest Maven Plugin)

近期在appfuse看到使用webtest-maven-plugin实现Web应用的集成測试,研究了下。感觉很不错。对于Web应用自己主动构建很有帮助,在性能測试之前能够保证Web应用的基本功能工作正常,分享给大家。 WetTest工作原理 它是基于Ant来执行的Web页面的測试工具。通过执行不同的target,測试页面上面提供的全部功能。它的工作原理是运用比較出名的HtmlUni...

weixin_34023982的博客 137

基于 FastAPI + LangGraph + LLM 大语言模型的通用 Agent 多智能体系统架构设计与开发实战、产业应用

FastAPI是一个现代、快速(高性能)的Python Web框架,专门用于构建API。它由Sebastián Ramírez(@tiangolo)创建,基于Starlette(用于Web部分)和Pydantic(用于数据部分)构建。性能优先:FastAPI是当前最快的Python Web框架之一,性能与NodeJS和Go相当。这得益于其基于Starlette的异步架构,能够充分利用Python 3.6+的async/await特性。开发效率。

AI天才研究院 230

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

Maven实现Web应用集成測试自己主动化 -- 部署自己主动化(WebTest Maven Plugin)

上篇:Maven实现Web应用集成測试自己主动化 -- 測试自己主动化(WebTest Maven Plugin) 之前介绍了怎样在maven中使用webtest插件实现web的集成測试,这里有个遗留问题,就是在运行maven的intergation測试时候web应用已经部署在容器中处于in service的状态,那么web应用的部署能否够自己主动化呢?在我们公司的系统中,因为使用了...

weixin_30314631的博客 82

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

maven集成测试_与Maven的集成测试

maven集成测试 用Maven实施单元测试是很普通的事情,我们大多数人都熟悉项目结构以及单元测试所在的位置。 但是,集成测试是一种不同的情况,大多数情况下它们具有完全不同的要求。 例如,可以让您的单元测试在内存数据库中的h2上运行,但是在集成测试和复杂查询方面,最好是针对实际的关系数据库(如生产中使用的关系数据库)执行它们。 考虑上面的示例,我们的集成测试可能具有不同的配置和依赖性。 因...

cunhui1209的博客 501

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

【在 Spring MVC 中使用 WebMvcTest 注释】

添加所需的依赖项:在项目的构建配置文件中,如pom.xml或build.gradle中添加Spring MVC和测试相关的依赖项。创建测试类:创建一个新的测试类,并使用@RunWith和@SpringBootTest注解对测试类进行注解。可以使用MockMvc的perform方法来执行GET、POST、PUT、DELETE等不同类型的请求,并使用andExpect方法来验证响应的状态码、响应体等。测试将在独立的测试环境中运行,并使用模拟的请求和响应来测试Spring MVC组件的行为。

qq_31532979的贺公子之数据科学与艺术博客,致力于科技向善,拥抱开源,要用技术的影响力来领导团队,而不是威权和职位! 1700

Maven(23)如何使用Maven进行集成测试?

在Maven中进行集成测试通常涉及使用插件,该插件专门用于执行集成测试。

qq_43012298的博客 644

Maven插件学习(二)——测试插件maven-surefire-pluigin

maven测试插件

螺旋小蜗的专栏 2578

【Maven教程】(九):使用 Maven 进行测试——动态指定要运行的测试用例、包含与排除测试用例、测试报告、运行TestNG测试、重用测试代码 ~

本文的主题是Maven与测试的集成,不过在讲述具体的测试技巧之前先实现了背景案例的account-captcha模块,这一模块的测试代码也成了本章其他内容良好的素材。maven-surefire-plugin是Maven背后真正执行测试的插件,它有一组默认的文件名模式来匹配并自动运行测试类。用户还可以使用该插件来跳过测试、动态执行测试类、包含或排除测试等。maven-surefire-plugin能生成基本的测试报告,除此之外还能使用cobertura-maven-plugin生成测试覆盖率报告。

Technology changes the world of life 3053

测试开发基础 mvn test 利用 Maven Surefire Plugin 做测试用例基础执行管理_mvn 执行测试用例

事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

youpwwcc的博客 834

maven的使用

其实用maven已经一年多了,我们的自动化测试代码一年多以前就开始用maven管理了,之所以现在才写这篇笔记,是觉得有些东西虽然常常在用,还是得不时的温故温故,以免忘了。 当初选择maven,也没想那么多,主要是它管理jar比较方便,不像之前用ant的时候(后来才知道用ivy和ant配合,也可轻松管理依赖jar包:你在一个默认命名为ivy.xml的文件中为你的项目指定了依赖项。Ivy将...

weixin_30257433的博客 148

springboot三板斧之单元测试

在Spring Boot中,单元测试是一个重要的环节,它帮助开发人员确保他们的代码按预期工作并且在未来的维护中保持稳定。Spring Boot提供了多种工具和注解来支持单元测试,其中JUnit和Mockito是最常用的。

Neoest的博客 747
上一篇: 实战Nagios NSCA方式监控Linux系统资源使用情况 -- Nagios配置篇 -- 被监控端
下一篇: MySQL5.6 如何优化慢查询的SQL语句 -- 慢日志介绍
开心的D哥
博客等级 码龄22年 63粉丝 110原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值