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

make tests more approachable #1045

Merged
merged 15 commits into from
Jun 19, 2021
Merged

Conversation

adehad
Copy link
Contributor

@adehad adehad commented May 16, 2021

Changes

  1. Split the tests.py file into a series of smaller files.
  2. Use conftest.py to store the helper methods together with a new base test case for easy access to the same jira setUp()
  3. Made consistent use of pytest.skip vs unittest.skip, creating a broken_test shortcut to help with consistency
  4. removed bad logic in JIRAError that was supposed to be CI specific, but ended up doing exactly the same thing as normal
  5. 100% jira.exceptions coverage
  6. address a few of Codacity warnings from the original codebase
  7. start some ground work for testing both Cloud and Server instances, the JiraTestManager now accepts an argument to specify what instance to authenticate with (although currently cloud authentication doesn't work)

Change Reasoning:

The single test file with >2000 lines was not approachable to new/casual contributors. This made it more likely for bugs to sneak in.

The changes in this PR move the test setUp() and other helper methods into a separate conftest.py. This makes the actual test files simpler to understand.

The test files have also been named to be easier to to find where a new test should belong.
i.e. I have added a new feature relating to Attachment I can add a test in test_attachment.py.
Hopefully this naming scheme also makes it easier to remember that you can run tox -e py39 -- tests/resources/test_attachment.py to only test those tests.

I also think this approach may help a contributor who just wants to add tests, they can look at a coverage report, pick a test they want to add and probably find what file they should add the test to pretty quickly.

Todo

  • Add a helper method to JiraTestCase to skip if on Cloud/Server? won't do here
  • make jira.exceptions coverage 100%
  • Update readme with some suggestions on how to debug tests using VSCode
  • a lot of tests have been added to TestIssue e.g. for worklog and votes, that should be moved to a dedicated test_worklog / test_votes file

@adehad adehad added the chore label May 16, 2021
@studioj
Copy link
Collaborator

studioj commented May 16, 2021

like the idea!

@adehad adehad force-pushed the feature/makes_tests_more_approachable branch from 26e3ac7 to a47498f Compare May 18, 2021 18:26
@adehad adehad marked this pull request as ready for review May 18, 2021 18:42
@adehad adehad requested a review from studioj May 24, 2021 19:03
@studioj
Copy link
Collaborator

studioj commented May 24, 2021

Quite a diff :-)

@adehad
Copy link
Contributor Author

adehad commented May 24, 2021

Quite a diff :-)

it really is a bad habit of mine haha

@adehad adehad requested a review from ssbarnea May 28, 2021 16:37
@adehad adehad merged commit f96495a into master Jun 19, 2021
@delete-merged-branch delete-merged-branch bot deleted the feature/makes_tests_more_approachable branch June 19, 2021 11:29
svermeulen pushed a commit to svermeulen/jira that referenced this pull request Oct 31, 2021
* new files

* update readme on how to debug tests

* xpass now true pass

* test exceptions, remove bad CI logic

* resolution

* fix merge, use user_normal instead of user_admin

* add message to top of tests.py to guide new contributors

* cleanup testmanager init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants