问题
I'm testing my application using Geb, and I want to mantain session between tests so I can avoid to log in in every tests (this is annoying when watching the tests in the browser).
Is there a way to mantain the session?
回答1:
By default Geb test integrations clear all the cookies after every test which means that you loose your web sessions. You can easily change that behaviour by using the following configuration option in your GebConfig.groovy:
autoClearCookies = false
You can read more about using configuration here.
So yes, it is possible to maintain session between tests.
回答2:
If you are using Spock, one option that you can do is to structure your "features" (test methods) in a linear fashion and use the @Stepwise annotation on the class. This will ensure that the cookies and browser object are not reset/replaced between features/test-methods
回答3:
Yup, it isnt possible now. My specs start by logging in and finish by logging out.
来源:https://stackoverflow.com/questions/13575999/mantain-session-between-tests-using-geb