Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Isolation #82

Open
lukesneeringer opened this issue Feb 23, 2019 · 1 comment
Open

Test Isolation #82

lukesneeringer opened this issue Feb 23, 2019 · 1 comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: cleanup An internal cleanup or hygiene concern.

Comments

@lukesneeringer
Copy link
Contributor

I started writing a CRUD test today:

def test_crud_with_request_dict(identity):
    assert len(identity.list_users().users) == 0
    try:
        user = identity.create_user({
            'display_name': 'Guido van Rossum',
            'email': '[email protected]',
        })
        assert user.display_name == 'Guido van Rossum'
        assert user.email == '[email protected]'
        assert len(identity.list_users().users) == 1
        assert identity.get_user({
            'name': user.name,
        }).display_name == 'Guido van Rossum'
    finally:
        identity.delete_user({'name': user.name})

This made me realize that we may want some way of supporting Showcase-enforced test isolation. I need it to be the case that if something goes wrong in this test, that it does not cascade to a bunch of other tests. Basically a "okay, this test is over, drop any data changes it made in the Identity or Messaging services".

That said, this warrants discussion. We may not want to do this, and there are other options:

  • Making tests not care about the absolute state of the database (e.g. test that len increased by one, not that it is equal to one).
  • Make tests care about the absolute state of the database, but skip the test if a beginning-state guard clause fails. This will cause situations where one test failure will lead to a host of other tests being skipped. That is okay with me actually -- it will be easy to isolate the failure.

That said, some kind of "transaction with rollback" is probably the best thing.

@landrito landrito added enhancement priority: p2 Moderately-important priority. Fix may not be included in next release. labels Apr 5, 2019
@landrito
Copy link
Contributor

landrito commented Apr 5, 2019

This is a good idea. I think adding a method to the the testing service would be a good way to do this.

@JustinBeckwith JustinBeckwith added the type: cleanup An internal cleanup or hygiene concern. label Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: cleanup An internal cleanup or hygiene concern.
Projects
None yet
Development

No branches or pull requests

3 participants