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

External version of AssumptionViolatedException #818

Conversation

dhasday
Copy link
Contributor

@dhasday dhasday commented Feb 12, 2014

This is a pull-request for issue #390.

Just subclassing and deprecating the internal version and updating references. I'm wondering if there's a better package for the external version?

@kcooney
Copy link
Member

kcooney commented Feb 12, 2014

Thanks!

To make things more backwards-compatible, code in JUnit itself that catches AssumptionViolatedException should catch org.junit.internal.AssumptionViolatedException just in case third-party code is directly throwing org.junit.internal.AssumptionViolatedException

dhasday added a commit to dhasday/junit that referenced this pull request Feb 12, 2014
…ion junit-team#818

This allows backwards compatibility with third-party code that directly throws internal version
@dhasday
Copy link
Contributor Author

dhasday commented Feb 13, 2014

@kcooney I didn't consider it on the initial pass, but makes sense to maintain that functionality. I pushed a changeset this morning updating anywhere that catches AssumptionViolatedException and the corresponding handlers to expect the internal version.

@marcphilipp
Copy link
Member

One minor thing: The imports are not ordered alphabetically in a couple of places leading to unnecessary changes in some files, e.g. in ExpectException. Can you fix that?

@dhasday
Copy link
Contributor Author

dhasday commented Feb 14, 2014

@marcphilipp Serves me right for manually updating imports. I've fixed the import ordering to match coding standards for all modified files. There were a few extra fixes for some missing/extra blank lines and static imports below imports.

@kcooney
Copy link
Member

kcooney commented Feb 15, 2014

LGTM

@dsaff Did you want to take a look?

@dsaff
Copy link
Member

dsaff commented Feb 18, 2014

Also LGTM!

@marcphilipp
Copy link
Member

AssumptionViolatedExceptionTest should be moved to the new package, too.

@dhasday
Copy link
Contributor Author

dhasday commented Feb 21, 2014

@marcphilipp What's the preferred package style for tests that use experimental features?

@stefanbirkner
Copy link
Contributor

The test and the class under test should have the same package. Therefore src/test/java/org/junit/tests/experimental/AssumptionViolatedExceptionTest.java should be moved to src/test/java/org/junit/AssumptionViolatedExceptionTest.java.

@stefanbirkner stefanbirkner added this to the 4.12 milestone Feb 26, 2014
@pholser
Copy link
Contributor

pholser commented Feb 28, 2014

Looking forward to this one. I think, ultimately, specific assertion/assumption mechanisms (assertEquals, assumeThat, etc.) belong outside of the core of JUnit. AssertionError and AssumptionViolatedException represent implicit contracts between test and test runner, and can be satisfied in many ways (Hamcrest, etc.) Publishing AssumptionViolatedException will encourage fuller, alternative assertion/assumption mechanisms.

@dhasday
Copy link
Contributor Author

dhasday commented Mar 1, 2014

Alright, finally got around to moving the test class. Anything left to do before this can be merged?

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.internal.AssumptionViolatedException;
Copy link
Member

Choose a reason for hiding this comment

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

The Stopwatch class hasn't been released yet. Could you please update the Javadoc to use the external version of AssumptionViolatedException instead?

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 usage in Stopwatch is overriding a method from TestWatcher so I can't update this reference without changing existing APIs

@kcooney
Copy link
Member

kcooney commented Mar 2, 2014

Thanks!

Besides Stopwatch, do any other public APIs use AssumptionViolationException in a method signature?

@stefanbirkner
Copy link
Contributor

I found no further usage of AssumptionViolationException.

@@ -1,6 +1,5 @@
package org.junit.tests.experimental.theories.extendingwithstubs;


Copy link
Contributor

Choose a reason for hiding this comment

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

Could you revert this change, please. This file should not be part of the issues change list, because there is no real edit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks.

@stefanbirkner
Copy link
Contributor

Looks good.

Can you please squash the commits 92c8319, 22b0d30, f7ed086 and 840d78f. These are all commits but baae295 which reorders the imports. (If you're not familiar with git rebase, please let me know.)

… in org.junit.internal

Allows developers to write code that handles assumption violations without depending on internal classes
@dhasday
Copy link
Contributor Author

dhasday commented Mar 5, 2014

@stefanbirkner The commits should be squashed now with a few additional updates.

I noticed that I only made aesthetic changes to TestWatcherTest and StopwatchTest, so I reverted those. Also, I guess I forgot to run tests after moving AssumptionViolatedExceptionTest so I updated the import in AllTests to fix the compile error.

stefanbirkner added a commit that referenced this pull request Mar 5, 2014
…eption

External version of AssumptionViolatedException
@stefanbirkner stefanbirkner merged commit 95f56b3 into junit-team:master Mar 5, 2014
@stefanbirkner
Copy link
Contributor

Thanks.

@dhasday dhasday deleted the external-assumption-violated-exception branch March 5, 2014 23:58
@dhasday dhasday restored the external-assumption-violated-exception branch March 5, 2014 23:58
@dhasday dhasday deleted the external-assumption-violated-exception branch March 6, 2014 00:00
kcooney added a commit to kcooney/junit that referenced this pull request Sep 11, 2014
kcooney added a commit to kcooney/junit that referenced this pull request Sep 11, 2014
marcphilipp added a commit that referenced this pull request Sep 11, 2014
Update release notes to include pulls #818 and #985
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.

6 participants