grails 集成测试用例保留数据以供调查
我们习惯于针对内存中的 HSQLDB 数据库运行 grails 集成测试,但在故障点,由于数据丢失而很难调查。我们迁移到针对物理数据库(postgres)运行测试,当测试通过时一切都很好。在任何时候,如果测试失败,我们都希望将数据提交到数据库中,以便事后分析测试失败的原因。
总而言之,我们希望只要测试通过,测试就以回滚模式运行,以便一个测试不会影响另一个测试,并且在测试第一次失败时,在该点提交数据并停止。
我们花费了大量的时间来调查集成测试失败,并且想知道 grails 中是否有任何选项可以在第一次集成测试失败时停止,并将数据保存在数据库中以供调查。我搜索了一下,没有找到任何合适的指针。如果您遵循任何其他实践来解决集成测试问题,并且是否值得分享,请告诉我们。
We were used to running our grails integration test against in memory HSQLDB database, but at the failure point it was difficult to investigate as the data was lost. We migrated to running the test against the physical database(postgres) and all is well when the tests passes. At any point if the tests fail we want the data to be committed in the database for postmortem analysis as to why the test failed.
To summarize, we want the tests to run in rollback mode as long as the test passes so that one test doesn't affect the other test and on the first failure of a test, commit the data at that point and stop.
We spend considerable amount of time investigating the integration test failure and would like to know if we have any option in grails to stop at first integration test failure with data preserved in the database for investigation. I searched little and didn't find any suitable pointers. If you follow any other practice to troubleshoot integration test and if it is worth sharing please let us know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试简单的技巧:
在失败时设置全局标志,在每次测试中测试该标志。如果设置了标志则退出测试
Simple hack you could try:
set a global flag on failure, test for the flag in each test. if flag is set exit the test
最近我遇到了 Grails Guard 插件,我认为它在这种情况下很有用,因为除了更快地运行集成测试之外,
它还保留了测试运行后保存的数据。Recently I came across with Grails Guard Plugin and I think it can be useful in this case, because besides running integration tests faster,
it preserves the data saved after tests are run.