groovy脚本在groovyconsole中调试时异常

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

groovy脚本在groovyconsole中调试时异常

shuewah
groovy脚本在groovyconsole中调试时异常,提示:

Test Failure: initializationError(org.ngrinder.TestRunner)
java.lang.RuntimeException: Please add
-javaagent:D:\groovy-2.2.2\lib\grinder-dcr-agent-3.9.1.jar
in 'Run As JUnit' vm argument.

这个相关jar我已经复制到groovy安装目录的lib中,上述是什么原因导致,可以怎样解决
Reply | Threaded
Open this post in threaded view
|

Re: groovy脚本在groovyconsole中调试时异常

shuewah
in  'Run As JUnit' vm argument.

这个地方在哪边?貌似无处添加
Reply | Threaded
Open this post in threaded view
|

Re: groovy脚本在groovyconsole中调试时异常

Mavlarn

groovy脚本的运行,是用的我们实现的junit的runner运行的,而不是直接运行groovy脚本,所以,最好还是在eclipse里面运行。

  

调试groovy脚本最好的方法是创建脚本的时候生成groovy maven类型的脚本,它会生成一个maven项目,包括pom文件,和groovy代码。然后你可以用svn客户端,把生成项目checkout出来,导入到eclipse里面,就可以运行调试了。

 

你可以参考下面的文档:

http://www.cubrid.org/wiki_ngrinder/entry/install-groovy-ide 

http://www.cubrid.org/wiki_ngrinder/entry/import-groovy-maven-project-in-ide 

 

 

-----Original Message-----
From: "shuewah [via ngrinder]"<[hidden email]>
To: "Mavlarn"<[hidden email]>;
Cc:
Sent: 2014-04-28 (星期一) 16:22:45
Subject: Re: groovy脚本在groovyconsole中调试时异常

in  'Run As JUnit' vm argument.

这个地方在哪边?貌似无处添加


If you reply to this email, your message will be added to the discussion below:
http://ngrinder.642.n7.nabble.com/groovy-groovyconsole-tp1501p1502.html
To start a new topic under ngrinder-user-cn, email [hidden email]
To unsubscribe from ngrinder-user-cn, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: groovy脚本在groovyconsole中调试时异常

shuewah
参考下面的文档:

http://www.cubrid.org/wiki_ngrinder/entry/install-groovy-ide 

这个文档中的步骤4从哪边切入,找不到这个

Restart Eclipse and and select SVN Kit 1.7.8. Subversion repo provided by nGrinder is compatible with above SVN Kit 1.7.8.
Then click “Next”s and “Finish”s and restart Eclipse until the installation is completed.
Reply | Threaded
Open this post in threaded view
|

Re: groovy脚本在groovyconsole中调试时异常

Mavlarn

第三步是安装svn的插件,重启以后,出现对话框只是说要设置使用的SVN的版本,可能新版本的插件没有这个对话框了。那是因为SVN1.7.8版本跟之前的版本不太兼容。如果没有出现第四步里面的对话框也没有关系。直接进行下一步。

 

 

 

-----Original Message-----
From: "shuewah [via ngrinder]"<[hidden email]>
To: "Mavlarn"<[hidden email]>;
Cc:
Sent: 2014-04-29 (星期二) 19:37:51
Subject: Re: groovy脚本在groovyconsole中调试时异常

参考下面的文档:

http://www.cubrid.org/wiki_ngrinder/entry/install-groovy-ide 

这个文档中的步骤4从哪边切入,找不到这个

Restart Eclipse and and select SVN Kit 1.7.8. Subversion repo provided by nGrinder is compatible with above SVN Kit 1.7.8.
Then click “Next”s and “Finish”s and restart Eclipse until the installation is completed.


If you reply to this email, your message will be added to the discussion below:
http://ngrinder.642.n7.nabble.com/groovy-groovyconsole-tp1501p1509.html
To start a new topic under ngrinder-user-cn, email [hidden email]
To unsubscribe from ngrinder-user-cn, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: groovy脚本在groovyconsole中调试时异常

shuewah
This post was updated on .
eclipse中导入maven工程后,默认创建的groovy脚本执行是OK的,但按下面网址步骤13,在脚本中加入 @Repeat(2)

http://www.cubrid.org/wiki_ngrinder/entry/import-groovy-maven-project-in-ide 

再次运行脚本后,就报错了:
Class not found TestRunner
java.lang.ClassNotFoundException: TestRunner
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)




================================================================================

相关脚本如下:
import static net.grinder.script.Grinder.grinder
import static org.junit.Assert.*
import static org.hamcrest.Matchers.*
import net.grinder.plugin.http.HTTPPluginControl;
import net.grinder.plugin.http.HTTPRequest
import net.grinder.script.GTest
import net.grinder.script.Grinder
import net.grinder.scriptengine.groovy.junit.GrinderRunner
import net.grinder.scriptengine.groovy.junit.annotation.BeforeThread
import net.grinder.scriptengine.groovy.junit.annotation.BeforeProcess
// import static net.grinder.util.GrinderUtils.* /** You can use this if you're using nGrinder after 3.2.3 */

import org.junit.BeforeClass
import org.junit.Test
import org.junit.runner.RunWith

import HTTPClient.HTTPResponse
import HTTPClient.NVPair

/**
 * A simple example using the HTTP plugin that shows the retrieval of a
 * single page via HTTP.
 *
 * This script is automatically generated by ngrinder.
 *
 * @author admin
 */

@Repeat(2)
@RunWith(GrinderRunner)
class TestRunner {

        public static GTest test
        public static HTTPRequest request

        @BeforeProcess
        public static void beforeProcess() {
                HTTPPluginControl.getConnectionDefaults().timeout = 6000
                test = new GTest(1, "192.168.19.9")
                request = new HTTPRequest()
                test.record(request)
                grinder.logger.info("before process.")
        }


        @BeforeThread
        public void beforeThread() {
                grinder.statistics.delayReports=true
                grinder.logger.info("before thread.")
        }

        @Test
        public void test(){
                HTTPResponse result = request.GET("http://192.168.19.9/s?wd=a")
                if (result.statusCode == 301 || result.statusCode == 302) {
                        grinder.logger.warn("Warning. The response may not be correct. The response code was {}.", result.statusCode)
                } else {
                        assertThat(result.statusCode, is(200))
                }
        }
}