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

Add Result#getAssumptionFailureCount #1294

Conversation

alb-i986
Copy link
Contributor

My original intent was to fix unit test assumeWithExpectedException: it was throwing AssumptionViolatedException thus being skipped (see #98).

It led me to adding Result#getAssumptionFailureCount.

Fix unit test assumeWithExpectedException: it was throwing AssumptionViolatedException thus being skipped (see junit-team#98).
assumeTrue(false);
public static class TestClassWithAssumptionFailure {

@Test(expected = IllegalArgumentException.class)
Copy link
Member

Choose a reason for hiding this comment

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

I know it was there before, but the expected parameter is confusing and should be removed.

Copy link
Contributor Author

@alb-i986 alb-i986 May 14, 2016

Choose a reason for hiding this comment

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

It was part of the scenario. It comes from the example given in the bug report: #98

@kcooney
Copy link
Member

kcooney commented May 14, 2016

This changes the serialized form of this class. Do we know if IDEs or build tools serialize it?

@marcphilipp
Copy link
Member

Good catch, @kcooney! I guess it's okay to add an instance variable, though. On the JVM with the old version of the class this field should just get ignored. But we should write a test for that scenario.

@marcphilipp
Copy link
Member

@alb-i986 Can you add such a test? Please let me know if you need help.

@kcooney
Copy link
Member

kcooney commented May 14, 2016

Here is how we worked around this problem last time: f6149a9

Due to that fix we might be safe.

Edit: just in case, getAssumptionFailureCount()should throw UnsupportedOperationException if called on a re-serialized instance.

@@ -156,13 +166,15 @@ public RunListener createListener() {
private static final long serialVersionUID = 1L;
private final AtomicInteger fCount;
private final AtomicInteger fIgnoreCount;
private final AtomicInteger assumptionFailureCount;
Copy link
Member

@kcooney kcooney May 15, 2016

Choose a reason for hiding this comment

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

I'm reasonably sure that if you add this, you'll be breaking serialization. It's possible that new code will be able to read objects serialized with old code (the tests in ResultTests.java check for that) but code linked against 4.12 won't be able to read Result objects serialized by versions after 4.12. That may break some build tools or IDEs.

Could we instead not add this field, and have the Result(SerializedForm) constructor set a field to indicate that the assumption failure count cannot be determined?

Edit: Actually, since you didn't modify SerializedForm.serialize(), this change won't break serialization, but the number of assumption failures will be lost when you serialize and deserialize. So with your current code, a deserialized Result instance will throw a NullPointerException when you call getAssumptionFailureCount()

@kcooney
Copy link
Member

kcooney commented May 16, 2016

According to http://www.jguru.com/faq/view.jsp?EID=5064 we can safely add new fields while still allowing code running with older versions of the class to read serialized data written by the newer version. So we just need to make sure that the class behaves well when it is deserialized from a binary form that was written by an older version (which didn't know about this new field). I suggest when this happens, calling getAssumptionFailureCount() should throw an exception.

@@ -87,6 +90,13 @@ public int getIgnoreCount() {
}

/**
* @return the number of tests skipped because of an assumption failure
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add:

@since 4.13

@kcooney
Copy link
Member

kcooney commented Aug 7, 2017

@alb-i986 did you have any time to fix the issues no this pull soon? If not, it won't make 4.13

@alb-i986
Copy link
Contributor Author

alb-i986 commented Aug 9, 2017

@kcooney when is 4.13 due?

@kcooney
Copy link
Member

kcooney commented Aug 10, 2017

@alb-i986 we don't have a due date, but it has been over two years since 4.12 was released, and there are few remaining open issues targeted to 4.13

@TWiStErRob
Copy link

bump, 4.13 is almost there...

@marcphilipp
Copy link
Member

@alb-i986 Any news? Please let us know if you can do the requested changes.

@kcooney
Copy link
Member

kcooney commented Jun 7, 2018

Replaced by #1530

@kcooney kcooney removed this from the 4.13 milestone Jun 7, 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
Development

Successfully merging this pull request may close these issues.

4 participants