4teamwork / ftw.builder

Builder pattern for creating Plone objects in tests
3 stars 0 forks source link

[UPDATED] Refactor sessions to not be singleton #4

Closed jone closed 11 years ago

jone commented 11 years ago

The zope.testing.cleanup functionality does not work for our use case: when using functional and integration testing with the same layer the cleanup is ran once after executing both, which might result in auto_commit enabled for the integration testing layer.

The BUILDER_AUTO_COMMIT layer resets the session after each test, which fixes the problem. But it the session is not reset when not using the BUILDER_AUTO_COMMIT.

(I'm working on the readme on a seperate branch, I'll document it there until it is in master too). /cc @senny @phgross

senny commented 11 years ago

What is the intention to configure the builder within ftw.builder and not inside the individual projects?

jone commented 11 years ago

The intention is to make it easy to use ftw.builder in functional tests without breaking test isolation.

When configuring the session in the a package specific fixture and using the this fixture for integration and functional testing (as it is done when using plone.app.testing the way it's meant to be used) it will result in commits in integration testing. This would cause bugs which are hard to trace.

Would you prefer to remove the auto_commit feature altogether? I'd either give the user a tool to do it right or let him do transaction.commit's manually..

senny commented 11 years ago

Why not turn auto-commit off by default?

jone commented 11 years ago

It is off by default, but if you just turn it on in setUp of the layer the isolation is gone

senny commented 11 years ago

maybe we should reevaluate the singleton approach... calling that reset method seems like a smell to me.

jone commented 11 years ago

@senny Update:

senny commented 11 years ago

looks great! This should go into the README ( #5 ) as well.