Peter
Peter

Reputation: 1021

Grails splitting geb tests

I am new to selenium tests in grails. I am using geb and spock for testing.

I want to split my test plans into some smaller test plans. I want to know if it's possible to make a spec which calls other specs?

Upvotes: 0

Views: 111

Answers (3)

Peter
Peter

Reputation: 1021

I found now another solution.

I make a simple groovy class:

class ReUseTest {
   def myTest(def spec) {
       when: 
          spec.at ConnectorsPage
       then: 
          spec.btnNewConnector.click()
 }

In my spec I can call this this like:

def "MyTest"() {
    specs.reuseable.ReUseTest myTest = new specs.reuseable.ReUseTest()
    specs.myTest(this)
}

I can now use this part in every spec.

Upvotes: 0

user6070112
user6070112

Reputation: 11

You can create traits for each of the modules , Exp: consider validations of entering details in form: Name,Contact details and other comments

Create a trait which has methods to fill these details and verify after saving these details

Use this trait in your spec.

This will make your code more readable and clear

Upvotes: 1

zypherman
zypherman

Reputation: 657

What you should do it have a 'Spec' for each area of the application. If that area has more than one scenarios then include them in the 'Spec' that matches that area. For Example.

LogInSpec Has a log in scenario. Form validation scenario. Log out scenario.

This way things stay organized and its easy to see what sections of your application are failing.

If your goal is to run these in parallel then I recommend that you try and keep tests even across the different test classes. This way they all take around the same amount of time.

Upvotes: 1

Related Questions