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

Fixed test status of optional in dataprovider test #256

Merged
merged 3 commits into from
Aug 11, 2022

Conversation

martingrossmann
Copy link
Contributor

Description

In case of optional assertions a testmethod was set to status SKIPPED if the test was part of a dataprovider run.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

log().debug("Asserting '{}' for '{}'", expectedStatus, methodNameSlug);
foundEntries.stream()
.filter(line -> line.contains(expectedStatus.title))
.findFirst()
Copy link

Choose a reason for hiding this comment

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

Would not anyMatch work just as well here? Or must we discard results after the first?
(value is unused, so we do not actually need a find operation.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does not work without value: () -> log().info(...) --> IntelliJ: Cannot infer functional interface type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And it's just a helper class for tests. ;-)

Copy link

Choose a reason for hiding this comment

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

I mean like this:

if (foundEntries.stream().anyMatch(line -> line.contains(expectedStatus.title))) {
  log().info("Found status {}", expectedStatus.title);
}
else {
  Assert.fail(String.format("'%s' should have status '%s'", methodNameSlug, expectedStatus));
}

?
value is unused in ifPresentOrElse, so we do not actually need a result item.

Copy link

Choose a reason for hiding this comment

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

(Or alternatively: Did you forget to output value in the ifPresent part?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because of unique combination of class and method I have one result or nothing.

And value is not needed in output, I dont want to log the whole line. But value must be declared.

@martingrossmann martingrossmann added this to the 2.1 milestone Jul 19, 2022
log().debug("Asserting '{}' for '{}'", expectedStatus, methodNameSlug);
foundEntries.stream()
.filter(line -> line.contains(expectedStatus.title))
.findFirst()
Copy link

Choose a reason for hiding this comment

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

I mean like this:

if (foundEntries.stream().anyMatch(line -> line.contains(expectedStatus.title))) {
  log().info("Found status {}", expectedStatus.title);
}
else {
  Assert.fail(String.format("'%s' should have status '%s'", methodNameSlug, expectedStatus));
}

?
value is unused in ifPresentOrElse, so we do not actually need a result item.

@martingrossmann martingrossmann merged commit 1f15ebd into master Aug 11, 2022
@martingrossmann martingrossmann deleted the fix/failed-dataprovider-status branch August 11, 2022 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants