Re: jdbc连接数据库,record无测试结果返回
Posted by junoyoon on
URL: http://ngrinder.373.s1.nabble.com/jdbc-record-tp871p876.html
If you're using groovy... you can use the following code. it's much easier.
package org.ngrinder;
import static net.grinder.script.Grinder.grinder
import static org.junit.Assert.*
import static org.hamcrest.Matchers.*
import net.grinder.script.GTest
import net.grinder.script.Grinder
import net.grinder.scriptengine.groovy.junit.GrinderRunner
import net.grinder.scriptengine.groovy.junit.annotation.BeforeProcess
import net.grinder.scriptengine.groovy.junit.annotation.BeforeThread
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Test
import org.junit.runner.RunWith
import groovy.sql.Sql
/**
* A simple example using the Groovy SQL that shows the retrieval of a
* Simple query.
*
* This script is automatically generated by ngrinder.
*
* @author 김성규
*/
@RunWith(GrinderRunner)
class TestRunner {
public static GTest test
public static sql
@BeforeProcess
public static void beforeProcess() {
test = new GTest(1, "Test1")
sql = Sql.newInstance( 'jdbc:cubrid:<DB Host>:<DB Port>:demodb:::', 'public', '', 'cubrid.jdbc.driver.CUBRIDDriver' )
test.record(sql);
grinder.logger.info("before process.");
}
@BeforeThread
public void beforeThread() {
grinder.statistics.delayReports=true;
grinder.logger.info("before thread.");
}
@Test
public void test(){
sql.eachRow( 'select * from code' ) { println "$it.s_name -- ${it.f_name} --" }
}
}