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

Pull request for issue #144 #542

Merged
merged 8 commits into from
Nov 14, 2012
Merged

Pull request for issue #144 #542

merged 8 commits into from
Nov 14, 2012

Conversation

coreyjv
Copy link
Contributor

@coreyjv coreyjv commented Nov 10, 2012

Added additional public method, reportMissingExceptionWithMessage, to ExpectedException rule to allow a
the specification of a custom message that would be thrown in the event a
test did not throw the expected exception. If one is not provided the
class falls back to the previous behavior.

Added additional public method, setMissingExceptionMessage, to allow a
user to specify a custom message that would be thrown in the event a
test did not throw the expected exception. If one is not provided the
class falls back to the previous behavior.
The test method name was never updated. Updated the test method name to
be consistent with what the test was executing.
* @return self
*/
public ExpectedException setMissingExceptionMessage(String providedMessage) {
missingExceptionMessage = providedMessage;
Copy link
Member

Choose a reason for hiding this comment

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

The indentation looks off here and in the other modified paces, it should be 4 spaces.

@marcphilipp
Copy link
Member

@coreyjv Looks good! I made a few comments inline.

@coreyjv
Copy link
Contributor Author

coreyjv commented Nov 10, 2012

@marcphilipp,

Since I'm still new to this do you want me to make those adjustments or is that something you do in the merge?

As far as the indentation I'm not sure what the problem is because I'm using the Eclipse project settings provided. Are there any in particular you'd like me to check?

Thanks!

@marcphilipp
Copy link
Member

You don't have to submit another request as you can simply make
changes on your branch by adding commits.

Unfortunately, the formatter setting are still not checked in, there
is another open issue where we are waiting for them to be checked in.

Changed method name from setMissingExceptionMessage to
reportMissingExceptionWithMessage to be more consistent with the
existing API.
Converted tabs to spaces for newly added code to be in line with
guidelines.
@coreyjv
Copy link
Contributor Author

coreyjv commented Nov 12, 2012

@marcphilipp, I believe I've made all the requested changes. Please let me know if you need anything else.

Thanks!

/**
* Specifies the detail message for an exception to be thrown if the test does
* not throw the expected exception.
* @param providedMessage exception detail message
Copy link
Member

Choose a reason for hiding this comment

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

The parameter is now called message.

@marcphilipp
Copy link
Member

@coreyjv Thanks! I've added two Javadoc-related comments inline.

@coreyjv
Copy link
Contributor Author

coreyjv commented Nov 12, 2012

@marcphilipp, I apologize for the Javadoc oversight. It should be all set now.

@marcphilipp
Copy link
Member

@coreyjv There's no need for apologies. :-)

@dsaff Looks good to me, can you take a look?

@Tibor17
Copy link
Contributor

Tibor17 commented Nov 12, 2012

@marcphilipp
@dsaff

Would you please again check the name of the method?

Above i asked you if we can rename it to something like

notifyUncaughtExceptionMessage()

or

notifyNotThrownExceptionMessage()

Instead of "missing" is supposed to use "NotThrown" or "Uncaught" matching Java API vocabulary.

Instead of "report" we use in our API "fire" or "notify", in Java API Logger is "log" or "record".

When you say notify, you do not have to say Message nor WithMessage, because implicitly can be notified only by a message/event.

thx

fail("Expected test to throw " + expectation);
String failureMessage;

if ( isMissingExceptionMessageEmpty() ) {
Copy link
Member

Choose a reason for hiding this comment

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

No extra spaces inside if(), please

@dsaff
Copy link
Member

dsaff commented Nov 13, 2012

@Tibor17, the current name seems fine to me.

@coreyjv
Copy link
Contributor Author

coreyjv commented Nov 13, 2012

@dsaff I'll try and get those changes done and committed this evening.

Refactored message decision logic out of failDueToMissingException into
its own method missingExceptionMessage.
@coreyjv
Copy link
Contributor Author

coreyjv commented Nov 13, 2012

@dsaff the requested changes are complete.

@dsaff
Copy link
Member

dsaff commented Nov 14, 2012

Thanks!

dsaff pushed a commit that referenced this pull request Nov 14, 2012
@dsaff dsaff merged commit ba7e1ce into junit-team:master Nov 14, 2012
@dsaff
Copy link
Member

dsaff commented Nov 14, 2012

@coreyjv, would you mind also updating the wiki at https://github.com/KentBeck/junit/wiki/Exception-testing to mention this new feature? Thanks!

@marcphilipp
Copy link
Member

@coreyjv @dsaff Merging this pull request broke the build: https://junit.ci.cloudbees.com/job/JUnit/9/console

I think String.isEmpty() has been added in JDK6. We are still trying to stay backwards compatible to JDK5, that's why the build runs with that JDK.

@coreyjv Do you have time to fix that?

@marcphilipp
Copy link
Member

We should probably state in the wiki that this is unreleased functionality, right?

@coreyjv
Copy link
Contributor Author

coreyjv commented Nov 14, 2012

I'll fix it this evening. I'm sorry about that. I tested the build locally
using the provided build file and didn't notice any errors. Are there other
configuration items that aren't part of the Eclipse project settings?

Thanks!

On Nov 14, 2012, at 16:14, Marc Philipp [email protected] wrote:

@coreyjv https://github.com/coreyjv @dsaff
https://github.com/dsaffMerging this pull request broke the build:
https://junit.ci.cloudbees.com/job/JUnit/9/console

I think String.isEmpty() has been added in JDK6. We are still trying to
stay backwards compatible to JDK5, that's why the build runs with that JDK.

@coreyjv https://github.com/coreyjv Do you have time to fix that?


Reply to this email directly or view it on
GitHubhttps://github.com/KentBeck/junit/pull/542#issuecomment-10384844.

@coreyjv
Copy link
Contributor Author

coreyjv commented Nov 14, 2012

I'll add a note about unreleased functionality this evening as well.

On Nov 14, 2012, at 16:17, Marc Philipp [email protected] wrote:

We should probably state in the wiki that this is unreleased functionality,
right?


Reply to this email directly or view it on
GitHubhttps://github.com/KentBeck/junit/pull/542#issuecomment-10385181.

@marcphilipp
Copy link
Member

@coreyjv The Eclipse project does have JDK5 set as execution environment and compiler compliance level. However, if you use a newer JDK, Eclipse will warn you, but you won't get any compile errors as long as you do not use any language features of JDK6 or JDK7. API changes such as String.isEmpty() will get through unnoticed.

@coreyjv
Copy link
Contributor Author

coreyjv commented Nov 14, 2012

@coreyjv
Copy link
Contributor Author

coreyjv commented Nov 14, 2012

@marcphilipp I've updated the wiki as well.

dsaff pushed a commit that referenced this pull request Nov 15, 2012
Fixed a JDK5 backwards compatibility issue introduced in Pull #542
@dsaff
Copy link
Member

dsaff commented Nov 15, 2012

So I looked at the wiki, and decided that, although I want to keep the docs current, spreading around unreleased functionality might be more confusing than helpful. So I moved your comment to the 4.12 unrelease notes: https://github.com/KentBeck/junit/wiki/4.12-release-notes.

Hopefully it won't be too hard for one of us to move it back when we release.

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.

None yet

5 participants