使用 Geb 维护测试之间的会话 [英] Mantain session between tests using Geb
问题描述
我正在使用 Geb 测试我的应用程序,我想在测试之间保持会话,这样我就可以避免登录每个测试(这在浏览器中观看测试时很烦人).
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).
有没有办法维持会话?
推荐答案
默认情况下,Geb 测试集成会在每次测试后清除所有 cookie,这意味着您会丢失 Web 会话.您可以使用 GebConfig 中的以下配置选项轻松更改该行为.groovy:
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.
这篇关于使用 Geb 维护测试之间的会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!