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

SOLR-12555: refactor tests in package org.apache.solr.search #464

Closed
wants to merge 2 commits into from

Conversation

barrotsteindev
Copy link
Contributor

Tests are refactored to use expectThrows instead of try/catch.

@barrotsteindev barrotsteindev changed the title WIP SOLR-12555: refactor tests for package org.apache.solr.search WIP SOLR-12555: refactor tests in package org.apache.solr.search Oct 7, 2018
Copy link
Contributor

@gerlowskija gerlowskija left a comment

Choose a reason for hiding this comment

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

A few messages seem a little off (I've pointed those out inline), but once those are fixed I think this is ready to commit.

//expected
}
assertFalse(equals);
expectThrows(AssertionError.class, "expected error, functions are not equal",
Copy link
Contributor

Choose a reason for hiding this comment

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

[0] Not suggesting you change it here, but....kindof weird that there's just not an assertFuncNotEquals

} catch(AssertionFailedError e) {
assertTrue("queries were not equal, as expected", true);
}
expectThrows(AssertionFailedError.class, "queries were not equal, as expected",
Copy link
Contributor

Choose a reason for hiding this comment

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

[-1] I think this exception message here is backwards. This assertion fails if the queries were equal, but the message indicates that the problem is that they were !=. Using the message from the original fail() invocation would probably work better here.

} catch(AssertionFailedError e) {
assertTrue("queries were not equal, as expected", true);
}
expectThrows(AssertionFailedError.class, "queries were not equal, as expected",
Copy link
Contributor

Choose a reason for hiding this comment

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

[-1] I think this exception message here is backwards. This assertion fails if the queries were equal, but the message implies that the problem is that they were !=. Using the message from the original fail() invocation would probably work better here ("queries should not have been equal")

assertTrue("queries were not equal, as expected", true);
}

expectThrows(AssertionFailedError.class, "queries were not equal, as expected",
Copy link
Contributor

Choose a reason for hiding this comment

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

[-1] ditto re: wrong String message in expectThrows here

fail("Cyclic alising not detected");
} catch (SolrException e) {
assertTrue(e.getCause().getMessage().contains("Field aliases lead to a cycle"));
} catch (SolrException ex) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[Q] Is there a reason that this example also couldn't be changed into an expectThrows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad,
I sort of missed that one.
Just pushed a new commit fixing it though.


version = version2;
final long prevVersion = version2;
Copy link
Contributor

Choose a reason for hiding this comment

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

[0] I'm still somewhat leery of changing how the version variables are used here. I agree with what seems like your intent here - that final variables often make it much easier to reason about Java code. But with how flaky the tests are, I'd rather not introduce such changes here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only problem is that if the variables are not final, they can not be used inside the lambda that is passed to expectThrows.
Should I just revert these changes?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oof, yeah good point, that would be a problem. No need to revert. I'll just need to pay particular attention to this class when testing things out.

@barrotsteindev barrotsteindev changed the title WIP SOLR-12555: refactor tests in package org.apache.solr.search SOLR-12555: refactor tests in package org.apache.solr.search Nov 3, 2018
@gerlowskija
Copy link
Contributor

Thanks again for the work Bar. I've merged this to master. Should see this PR get closed out shortly.

@asfgit asfgit closed this in f669a1f Nov 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants