2

I am currently using cucumber and databasecleaner to test my application. And currently in my env.rb i have the setup of the cleaner as:

DatabaseCleaner.strategy = :truncation, {:except => %w[TABLE]}
After do
  DatabaseCleaner.clean
end

This way I can keep the data in TABLE. But I would also like to keep a single entry in a different table between tests. Is there any way I can achieve that or do I have to recreate it all the time with a Before hook?

4

1 回答 1

0

我能想到这个黑客。在您的测试 ENV DB 的该表上添加一个ON DELETE trigger。触发器调用插入行的函数。如果行已经存在,您可能需要在函数中添加一个检查以不执行任何操作。

于 2012-12-12T13:18:04.430 回答