Skip to content

Issue #159 Diffing a table with an empty list: Added two tests diffin… #1194

New issue

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

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

Already on GitHub? # to your account

Merged
merged 2 commits into from
Aug 11, 2017
Merged

Issue #159 Diffing a table with an empty list: Added two tests diffin… #1194

merged 2 commits into from
Aug 11, 2017

Conversation

mlvandijk
Copy link
Member

@mlvandijk mlvandijk commented Aug 10, 2017

Summary

Added two tests for issue #159

Details

One test to verify that diffing a non-empty table with an empty table throws expected TableDiffException.
One test to verify that diffing an empty table with an empty list does not throw an Exception.

Motivation and Context

Show that the issue has been resolved

How Has This Been Tested?

Test code only, to show issue has been resolved.

Types of changes

  • [ x] 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).

Checklist:

  • [x ] I've added tests for my code.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Copy link
Contributor

@mpkorstanje mpkorstanje left a comment

Choose a reason for hiding this comment

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

Code looks clean. Formatting looks good.

Unfortunately neither test case ever reaches the assertion. You can avoid this by making the test fail first before making it pass. So rather then using assertEquals(expected, actual) you could use an assertion that always fails assertEquals("notTheResultEver", actual).

Note that in case of empty_list_should_not_diff_with_empty_table no assertion is needed but you might want to start of by adding a failing one nonetheless.

try {
DataTable emptyTable = DataTable.create(Collections.emptyList());
table().diff(emptyTable);
} catch (IndexOutOfBoundsException e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You are expecting the test to throw a TableDiffException but catching an IndexOutOfBoundsException. I don't think this is quite right.

List<List<String>> emptyList = new ArrayList<List<String>>();
DataTable emptyTable = DataTable.create(Collections.emptyList());
emptyTable.diff(emptyList);
} catch (IndexOutOfBoundsException e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

In this test case we want to compare the empty table another another empty table. This should not result in any exception.

@mlvandijk
Copy link
Member Author

@mpkorstanje Thanks for your feedback! Made some changes, hope it's ok now.

@mpkorstanje mpkorstanje merged commit 194eeac into cucumber:master Aug 11, 2017
@olleolleolle
Copy link

@mlvandijk Hooray!

@mpkorstanje
Copy link
Contributor

Thank you!

I've squashed your commits and somewhat edited the commit message for brevity and clarity. You can read How to Write a Git Commit Message and Why sqaush git commits for a more detailed explanation. We're not religious about it but it does improve communication.

One more thing to do: Update History.md with your contribution. If the commit-bit-bot is working you should have been granted commit access.

mlvandijk added a commit that referenced this pull request Aug 11, 2017
@mlvandijk mlvandijk deleted the bug-159-diff-empty-table branch August 11, 2017 12:43
@mlvandijk
Copy link
Member Author

mlvandijk commented Aug 11, 2017

@mpkorstanje Updated History.md (with shorter/clearer commit message - I hope). Great links, thanks!

@lock
Copy link

lock bot commented Oct 24, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 24, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants