nGrinder Maven工程使用
1:新建Maven groovy工程
2:SVN Checkout Maven工程
3:新建JUnit脚本,并运行,提示报错
java.lang.RuntimeException: Please add
-javaagent:/Users/xx/.m2/repository/net/sf/grinder/grinder-dcr-agent/3.9.1/grinder-dcr-agent-3.9.1.jar
in 'Run As JUnit' vm argument.
4:Edit Run Configuration
VM options添加
-ea -javaagent:/Users/xx/.m2/repository/net/sf/grinder/grinder-dcr-agent/3.9.1/grinder-dcr-agent-3.9.1.jar
5:Maven 工程目录结构
6:修改pom.xml 文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ngrinder</groupId>
<artifactId>test</artifactId>
<version>0.0.1</version>
<properties>
<ngrinder.version>3.4</ngrinder.version>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>ngrinder.maven.repo</id>
<url>https://github.com/naver/ngrinder/raw/ngrinder.maven.repo/releases</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.ngrinder</groupId>
<artifactId>ngrinder-groovy</artifactId>
<version>${ngrinder.version}</version>
<scope>provided</scope>
</dependency>
<!-- 添加依赖 -->
<!--
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.0.1</version>
</dependency>
-->
<!-- 添加你的私有库依赖 -->
<!--
<dependency>
<groupId>your_lib</groupId>
<artifactId>your_lib</artifactId>
<version>your_lib_version</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/hello.jar</systemPath>
</dependency>
-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<additionalProjectnatures>
<projectnature>
org.eclipse.jdt.groovy.core.groovyNature
</projectnature>
<projectnature>
org.eclipse.m2e.core.maven2Nature
</projectnature>
</additionalProjectnatures>
</configuration>
</plugin>
</plugins>
</build>
</project>
7:原理
当一个脚本在性能测试配置页被选中时,
controller 会自动监测此脚本是否在 ${name}/src/main/java 文件夹下,
同时监测 pom.xml 是否在基础文件夹(相对于当前 Groovy 工程)下。
如果 controller 检测到了它们,
在分发给代理之前 controller 将会递归的拷贝在 ${name}/src/main/resources 和 ${name}/src/main/java 目录下的文件到准备分发目录下。
下图说明了 SVN 中的每个文件夹是如何拷贝到准备分发目录的
在普通的 Jython 脚本和 Groovy 脚本中,
可以使用 “open(“./resources/resource1.txt”)” 或者 “new File(“./resources/resource1.txt”)加载资源文件。
然而在 Groovy 的 Maven 工程中将不可用。
我们不得不替换此路径到 classpath 的基础资源路径,确保可以在 IDE 中可以运行 Groovy 的 JUnit 测试用例,资源文件在分发拷贝时将会保持目录层次。
你可以使用下面的代码加载资源文件
import org.codehaus.groovy.reflection.ReflectionUtils;
....
class YourTest {
String text;
@BeforeThread
public void beforeThread() {
// In groovy, InputStream contains text field.
text = loadResourceFromClassPath("/resource1.txt").text;
}
@Test
public void doTest() {
....
}
// This is groovy way to load resource from classpath
public loadResourceFromClassPath(String resourcePath) {
return ReflectionUtils.getCallingClass(0).getResourceAsStream(resourcePath);
}
}
nGrinder Maven工程使用的更多相关文章
- Eclipse创建Maven工程报错
问题 用Eclipse创建maven工程的时候,总是会报错,例如提示: Unable to create project from archetype [org.apache.maven.archet ...
- Eclipse中一个Maven工程的目录结构
在之前的javaSE开发中,没有很关注Eclipse工程目录下的环境,总是看见一个src就点进去新建一个包再写一个class.以后的日子中也没有机会注意到一个工程到底是怎么组织的这种问题,跟不要说自己 ...
- Mac下maven工程的创建,并搭建SSH环境
最近项目有用到maven,就特地学了一下.maven的一句话攻略就是,项目托管.帮你解决各种项目琐事:清理,导包....等等. 首先先到apach官网去下载一个maven的包,http://maven ...
- 导入maven工程错误
有时候导入maven工程会报空指针异常: An internal error occurred during: “Updating Maven Project”. java.lang.NullPoin ...
- MyEclipse创建Maven工程
先要在MyEclipse中对Maven进行设置:
- Maven工程引入jar包
Maven项目引入jar包的方法 法一.手动导入:项目右键—>Build Path—>Configure Build Path—>选中Libraries—>点击Add Exte ...
- 构建简单的Maven工程,使用测试驱动的方式开发项目
构建简单的Maven工程很简单,这里写这篇随笔的原因是希望自己能记住几个小点. 一.安装Maven 1.下载maven:https://maven.apache.org/download.cgi 2. ...
- 002商城项目:maven工程的测试以及svn的使用
我们上一篇文章搭建了maven工程,这一篇文章我们就要测试这个工程. 1: 由于这个工程还没有页面,我们要首先建立一个页面.在建立页面的jsp的过程中,我发现了一个问题,我这个eclipse由于缺少J ...
- 001淘淘商城项目:项目的Maven工程搭建
开始一个新的项目,特此记录,资料全部来源于传智播客,感谢. 我们要做一个类似电商的项目.用maven做管理. maven里面主要分为三种工程: 1:pom工程:用在父级工程,聚合工程中 2:war工程 ...
随机推荐
- SQL 的约束
说明:文章所有内容均截选自用户"实验楼包工头"发布在实验楼上的教程[MySQL 基础课程],想要详细的学习SQL,点击教程即可免费学习了:未经允许,禁止转载: 约束是一种限制,它通 ...
- python one
哈哈,今天把它搞了 谁? Python啊! ..... *************************************** python:解释性语言,功能很强大,现在很有市场! & ...
- eclipse 把鼠标指针放在错误的语句上 提示快速修正 不见了的解决方法
Window->Preferences->Java->Editor->Hovers 将[Combined Hover]选择即可,如果第一个[Variable Values]已经 ...
- MySQL主从同步问题
1,The replication receiver thread cannot start because the master has GTID_MODE = OFF and this serve ...
- UVA 11178 Morley's Theorem(几何)
Morley's Theorem [题目链接]Morley's Theorem [题目类型]几何 &题解: 蓝书P259 简单的几何模拟,但要熟练的应用模板,还有注意模板的适用范围和传参不要传 ...
- es6proxy
Proxy 支持的拦截操作一览. 对于可以设置.但没有设置拦截的操作,则直接落在目标对象上,按照原先的方式产生结果. (1)get(target, propKey, receiver) 拦截对象属性的 ...
- mac install wget
没有Wget的日子是非常难过的,强大的Mac OS 下安装Wget非常简单 下载一个Wget的源码包,http://www.gnu.org/software/wget/ ftp下载地址:ftp://f ...
- 在Windows10中运行debug程序
下载debug.exe 下载DOSBox 安装DOXBox,尽量不要装在C盘 将debug.exe放到F:/TASM 运行DOSBox.exe,执行 mount c f:\TASM #挂载目录 c: ...
- Robotframework 3- 安装
1. 安装, python3 安装好后,在cmd中运行 pip install robotframework # Install the latest version (does not upgrad ...
- Java多线程-----创建线程的几种方式
1.继承Thread类创建线程 定义Thread类的子类,并重写该类的run()方法,该方法的方法体就是线程需要完成的任务,run()方法也称为线程执行体 创建Thread子类的实例,也就是创建 ...