How would I go about running geb tests in JMeter?
I have compiled a jar of my test and have created a BSF sampler in JMeter. I have installed the groovy plugin for Jmeter.
My test class looks something like this:
class LoginLogoutTest extends GebSpec {
def "Login Logout"() {
given: "Go to the Login Page"
LoginPage loginPage = to LoginPage
when:
loginPage.login("admin", "password")
then:
DashboardPage dashboardPage = at DashboardPage
when:
dashboardPage.logout()
then:
waitFor {at LoginPage}
}
}
I've used Gradle to build the jar with all the required dependencies for this test class.
Then in my JMeter BSF sampler I have set the language to groovy and written the following script. My web-test.jar is in JMeters \lib directory as some tutorials have shown.
import com.geb.tests.LoginLogoutTest;
LoginLogoutTest myTest = new LoginLogoutTest();
myTest."Login Logout"(); //if commented out i get no errors
When I try to call the "Login Logout"() function JMeter throws the follolwing exception:
WARN - jmeter.protocol.java.sampler.BSFSampler: BSF error org.apache.bsf.BSFException: exception from Groovy: groovy.lang.MissingFieldException: No such field: $spock_sharedField__browser for class: org.codehaus.groovy.runtime.NullObject
If I don't call the method Jmeter does not throw any errors so I'm assuming I am initializing the class from my jar correctly in my JMeter script.
The reason for doing this is so we can perform load testing by running multiple threads of this test using PhantomJs.