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

Use isEmpty() and simplified assertions in Test #8473

Merged
merged 13 commits into from
Sep 27, 2023

Conversation

StefanSpieker
Copy link
Contributor

@StefanSpieker StefanSpieker commented Sep 10, 2023

Use isEmpty() and simplified assertions in Test

Testing done

Unit Tests still pass locally

Proposed changelog entries

  • N/A

Proposed upgrade guidelines

N/A

Submitter checklist

  • The Jira issue, if it exists, is well-described.
  • The changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developers, depending on the change) and are in the imperative mood (see examples). Fill in the Proposed upgrade guidelines section only if there are breaking changes or changes that may require extra steps from users during upgrade.
  • There is automated testing or an explanation as to why this change has no tests.
  • New public classes, fields, and methods are annotated with @Restricted or have @since TODO Javadocs, as appropriate.
  • New deprecations are annotated with @Deprecated(since = "TODO") or @Deprecated(forRemoval = true, since = "TODO"), if applicable.
  • New or substantially changed JavaScript is not defined inline and does not call eval to ease future introduction of Content Security Policy (CSP) directives (see documentation).
  • For dependency updates, there are links to external changelogs and, if possible, full differentials.
  • For new APIs and extension points, there is a link to at least one consumer.

Desired reviewers

Before the changes are marked as ready-for-merge:

Maintainer checklist

  • There are at least two (2) approvals for the pull request and no outstanding requests for change.
  • Conversations in the pull request are over, or it is explicit that a reviewer is not blocking the change.
  • Changelog entries in the pull request title and/or Proposed changelog entries are accurate, human-readable, and in the imperative mood.
  • Proper changelog labels are set so that the changelog can be generated automatically.
  • If the change needs additional upgrade steps from users, the upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).
  • If it would make sense to backport the change to LTS, a Jira issue must exist, be a Bug or Improvement, and be labeled as lts-candidate to be considered (see query).

@NotMyFault NotMyFault added the skip-changelog Should not be shown in the changelog label Sep 10, 2023
@MarkEWaite MarkEWaite self-assigned this Sep 10, 2023
@MarkEWaite
Copy link
Contributor

This PR is now ready for merge. We will merge it after approximately 24 hours if there is no negative feedback.

@MarkEWaite MarkEWaite added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Sep 11, 2023
@@ -487,7 +487,7 @@ private String callDependerValue() throws Exception {
// Check that the basic API endpoint invocation works.
assertEquals("ok", response.getString("status"));
JSONArray data = response.getJSONArray("data");
assertTrue(data.size() > 0);
assertFalse(data.isEmpty());
Copy link
Member

@jtnord jtnord Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both of these are not great - if it fails it does not give you hints as to why it fails - what was in the data is a great hint for analysis.

E.g.
assertThat(data, empty()) would be preferable here as it would produce something like expected an empty collection but got ["some", "Collection", "with", "values"] (hamcrest javadoc, other asserts libraries also available)

Copy link
Member

@jtnord jtnord Sep 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

y'all should have bashed me over the head.
as this would only fail if the collection was empty there is no additional information to be gleaned in this case. An empty collection is an empty collection no matter what diagnostics you add.
The inverse (when checking it is empty) is not the case - but these where asserting something was not empty, not that it was empty.

My apologies @StefanSpieker

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we all got a little confused :) But now it is really better than before :)

@NotMyFault NotMyFault removed the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Sep 12, 2023
@NotMyFault
Copy link
Member

@StefanSpieker Would you mind addressing the feedback from jtnord?

@jtnord
Copy link
Member

jtnord commented Sep 18, 2023

something is not empty (and we have some info about it)!

https://github.com/jenkinsci/jenkins/pull/8473/checks?check_run_id=16857757226

@jtnord
Copy link
Member

jtnord commented Sep 25, 2023

/label ready-for-merge

@comment-ops-bot
Copy link

I wasn't able to add the following labels: ready

Check that the label exists and is spelt right then try again.

@jtnord
Copy link
Member

jtnord commented Sep 25, 2023

/label ready-for-merge

@comment-ops-bot comment-ops-bot bot added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Sep 25, 2023
@NotMyFault NotMyFault merged commit 87888c7 into jenkinsci:master Sep 27, 2023
16 checks passed
@StefanSpieker StefanSpieker deleted the minor_refactoring_in_tests branch September 27, 2023 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback skip-changelog Should not be shown in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants