1
votes

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.

2
Why would you run Geb tests from jmeter? - tim_yates

2 Answers

0
votes

You can use Groovy Out of the box in JMeter through JSR223 Samplers:

  • Before JMeter 3.0 , download Groovy, copy embeddable/groovy-all.jar to jmeter/lib and restart JMeter

  • Starting from JMeter 3.0, Groovy is embedded

0
votes

I was able to find a Spock sampler for JMeter that works. I'm able to run my tests. Here's the link if anyone else is interested. JMeter Spock Sampler However, when running single threaded tests, just to see that the sampler works, the chrome browser stays open. Not quite sure why. This would be an issue when running multiple thread because there would be many browsers left open. The goal is to use a headless browser, phantomjs, which I've also gotten to work. But if I run multiple threads with the headless browser there are multiple instances left behind and visible in the windows task manage process list lol.