Skip to content

Unit tests for diff take 25 seconds #829

Closed
@dmpetrov

Description

@dmpetrov

Description

Our unit test suite becoming supper slow (lib unit-test time takes 58 seconds!) and useless as a result (now I cannot run it for every change I do - which works just fine before).

We need to reduce it's unit-tests run-time significantly (5-10 times).

I see multiple anti-patterns but I'm sure there are more:

  1. Too many pytest.mark.parametrize

The test below generates 50+ tests without a good reason. For example - there is not need to test save() in diff test - tests have to be "orthogonal". It needs to be replaced by 7-15 smaller tests.

@pytest.mark.parametrize("added", (True, False))
@pytest.mark.parametrize("deleted", (True, False))
@pytest.mark.parametrize("modified", (True, False))
@pytest.mark.parametrize("same", (True, False))
@pytest.mark.parametrize("status_col", ("diff", None))
@pytest.mark.parametrize("save", (True, False))
def test_compare(test_session, added, deleted, modified, same, status_col, save):
    ...
  1. Touching cloud resources

It looks like test_resolve_file() and such require access to clouds.

E               pytest_servers.exceptions.RemoteUnavailable: gs: Failed to setup mock remote: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

Version Info


Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions