-
Notifications
You must be signed in to change notification settings - Fork 164
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
simplified some assertions by using #containsExactly #68
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ public void testConvertShouldCreateEmptyVarargsArrayForMissingOnlyVarargsArgumen | |
Object[] result = underTest.convert(data, true, parameterTypes); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { new int[0] }); | ||
assertThat(result).containsExactly(new int[0]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I really prefer the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I more or less did a mechanical replacement. I agree, if the Of course it up to you, as it's your project. 😄 |
||
} | ||
|
||
@Test | ||
|
@@ -51,7 +51,7 @@ public void testConvertShouldCreateEmptyVarargsArrayForLastMissingVarargsArgumen | |
Object[] result = underTest.convert(data, true, parameterTypes); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { "test", new int[0] }); | ||
assertThat(result).containsExactly("test", new int[0]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
} | ||
|
||
@Test | ||
|
@@ -64,7 +64,7 @@ public void testConvertShouldCreateVarargsArrayForOneOnlyVarargsArguments() { | |
Object[] result = underTest.convert(data, true, parameterTypes); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { new double[] { 1.0 } }); | ||
assertThat(result).containsExactly(new double[] { 1.0 }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here |
||
} | ||
|
||
@Test | ||
|
@@ -77,7 +77,7 @@ public void testConvertShouldCreateVarargsArrayForOneLastVarargsArguments() { | |
Object[] result = underTest.convert(data, true, parameterTypes); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { 'a', (byte) 2, new double[] { 1.0 } }); | ||
assertThat(result).containsExactly('a', (byte) 2, new double[] { 1.0 }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here |
||
} | ||
|
||
@Test | ||
|
@@ -90,7 +90,7 @@ public void testConvertShouldCreateVarargsArrayForMultipleOnlyVarargsArguments() | |
Object[] result = underTest.convert(data, true, parameterTypes); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { new long[] { 1, 2, 3 } }); | ||
assertThat(result).containsExactly(new long[] { 1, 2, 3 }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as well as here |
||
} | ||
|
||
@Test | ||
|
@@ -103,7 +103,7 @@ public void testConvertShouldCreateVarargsArrayForMultipleLastVarargsArguments() | |
Object[] result = underTest.convert(data, true, parameterTypes); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { "foobar", new long[] { 1, 2, 3 } }); | ||
assertThat(result).containsExactly("foobar", new long[] { 1, 2, 3 }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here ... |
||
} | ||
|
||
@Test | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,7 +81,7 @@ public void testConvertShouldCorrectlyParseAllPrimitiveTypes() { | |
Object[] result = underTest.convert(data, false, parameterTypes, dataProvider, 10); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { true, (byte) 1, 'c', (short) 2, 3, 4L, 5.5f, 6.6d }); | ||
assertThat(result).containsExactly(true, (byte) 1, 'c', (short) 2, 3, 4L, 5.5f, 6.6d); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here |
||
} | ||
|
||
@Test | ||
|
@@ -96,7 +96,7 @@ public void testConvertShouldCorrectlyParseAllPrimitiveTypesAsJavaString() { | |
Object[] result = underTest.convert(data, false, parameterTypes, dataProvider, 11); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { -5, 2014l, -1.234567f, -0.901d }); | ||
assertThat(result).containsExactly(-5, 2014l, -1.234567f, -0.901d); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here |
||
} | ||
|
||
@Test | ||
|
@@ -111,7 +111,7 @@ public void testConvertShouldNotTrimValuesIfSettingsTrimIsFalse() { | |
Object[] result = underTest.convert(data, false, parameterTypes, dataProvider, 12); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { " foo", " bar ", "baz " }); | ||
assertThat(result).containsExactly(" foo", " bar ", "baz "); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here |
||
} | ||
|
||
@Test | ||
|
@@ -128,7 +128,7 @@ public void testConvertShouldTrimAndParseAllPrimitiveTypesIfSettingsTrimIsTrue() | |
Object[] result = underTest.convert(data, false, parameterTypes, dataProvider, 13); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { false, (byte) 11, 'z', (short) 22, 33, 44L, 55.55f, 66.66d }); | ||
assertThat(result).containsExactly(false, (byte) 11, 'z', (short) 22, 33, 44L, 55.55f, 66.66d); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and also here because it is really about the |
||
} | ||
|
||
@Test | ||
|
@@ -144,7 +144,7 @@ public void testConvertShouldTrimNonSpaceWhitespaceCharsIfSettingsTrimIsTrue() { | |
Object[] result = underTest.convert(data, false, parameterTypes, dataProvider, 20); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { -1f, -2, 3d }); | ||
assertThat(result).containsExactly(-1f, -2, 3d); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here |
||
} | ||
|
||
@Test | ||
|
@@ -160,7 +160,7 @@ public void testConvertShouldNotTrimNonBreakingSpaceEvenIfSettingsTrimIsTrue() { | |
Object[] result = underTest.convert(data, false, parameterTypes, dataProvider, 21); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { "\u00A0test\u00A0" }); | ||
assertThat(result).containsExactly("\u00A0test\u00A0"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here |
||
} | ||
|
||
@Test | ||
|
@@ -176,7 +176,7 @@ public void testConvertShouldCorrectlyHandleLeadingEmptyString() { | |
Object[] result = underTest.convert(data, false, parameterTypes, dataProvider, 30); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { "", true }); | ||
assertThat(result).containsExactly("", true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here |
||
} | ||
|
||
@Test | ||
|
@@ -192,7 +192,7 @@ public void testConvertShouldCorrectlyHandleTrailingEmptyString() { | |
Object[] result = underTest.convert(data, false, parameterTypes, dataProvider, 31); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { 1, "" }); | ||
assertThat(result).containsExactly(1, ""); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here |
||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
|
@@ -264,7 +264,7 @@ public void testConvertShouldCorrectlyParseEnum() { | |
Object[] result = underTest.convert(data, false, parameterTypes, dataProvider, 50); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { TestEnum.VAL1, TestEnum.VAL2 }); | ||
assertThat(result).containsExactly(TestEnum.VAL1, TestEnum.VAL2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here |
||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
|
@@ -292,7 +292,7 @@ public void testConvertShouldCorrectlyParseEnumIgnoringCase() { | |
Object[] result = underTest.convert(data, false, parameterTypes, dataProvider, 50); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { TestEnum.VAL1, TestEnum.VAL2 }); | ||
assertThat(result).containsExactly(TestEnum.VAL1, TestEnum.VAL2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here |
||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
|
@@ -322,7 +322,7 @@ public void testConvertShouldCorrectlyParseClass() { | |
Object[] result = underTest.convert(data, false, parameterTypes, dataProvider, 50); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { Thread.class, DataProviderRunner.class }); | ||
assertThat(result).containsExactly(Thread.class, DataProviderRunner.class); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here |
||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
|
@@ -352,9 +352,9 @@ public void testConvertShouldCorrectlyParseAllPrimitiveWrapperTypes() { | |
Object[] result = underTest.convert(data, false, parameterTypes, dataProvider, 60); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo( | ||
new Object[] { Boolean.TRUE, Byte.valueOf((byte) 1), Character.valueOf('c'), Short.valueOf((short) 2), | ||
Integer.valueOf(3), Long.valueOf(4L), Float.valueOf(5.5f), Double.valueOf(6.6d) }); | ||
assertThat(result).containsExactly( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. everywhere here |
||
Boolean.TRUE, Byte.valueOf((byte) 1), Character.valueOf('c'), Short.valueOf((short) 2), | ||
Integer.valueOf(3), Long.valueOf(4L), Float.valueOf(5.5f), Double.valueOf(6.6d)); | ||
} | ||
|
||
@Test | ||
|
@@ -369,7 +369,7 @@ public void testConvertShouldParseNullValuesAsStringIfSettingsConvertNullsIsFals | |
Object[] result = underTest.convert(data, false, parameterTypes, dataProvider, 70); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { "null", "null" }); | ||
assertThat(result).containsExactly("null", "null"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and so on ... |
||
} | ||
|
||
@Test | ||
|
@@ -385,7 +385,7 @@ public void testConvertShouldParseNullValuesAsNullObjectIfSettingsConvertNullsIs | |
Object[] result = underTest.convert(data, false, parameterTypes, dataProvider, 71); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { null, null, "foo" }); | ||
assertThat(result).containsExactly(null, null, "foo"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here, but maybe you have a reason why this does not matter or why my gut feeling maybe betray me ... |
||
} | ||
|
||
@Test | ||
|
@@ -400,7 +400,7 @@ public void testConvertShouldCorrectlyUseConstructorWithSingleStringArgForBigInt | |
Object[] result = underTest.convert(data, false, parameterTypes, dataProvider, 80); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { BigInteger.valueOf(1) }); | ||
assertThat(result).containsExactly(BigInteger.ONE); | ||
} | ||
|
||
@Test | ||
|
@@ -415,7 +415,7 @@ public void testConvertShouldCorrectlyUseConstructorWithSingleStringArgForFile() | |
Object[] result = underTest.convert(data, false, parameterTypes, dataProvider, 80); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { new File("home/schmida") }); | ||
assertThat(result).containsExactly(new File("home/schmida")); | ||
} | ||
|
||
@Test | ||
|
@@ -430,7 +430,7 @@ public void testConvertShouldCreateEmptyVarargsArrayForMissingOnlyVarargsArgumen | |
Object[] result = underTest.convert(data, true, parameterTypes, dataProvider, 90); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { new int[0] }); | ||
assertThat(result).containsExactly(new int[0]); | ||
} | ||
|
||
@Test | ||
|
@@ -445,7 +445,7 @@ public void testConvertShouldCreateEmptyVarargsArrayForLastMissingVarargsArgumen | |
Object[] result = underTest.convert(data, true, parameterTypes, dataProvider, 91); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { "test", new int[0] }); | ||
assertThat(result).containsExactly("test", new int[0]); | ||
} | ||
|
||
@Test | ||
|
@@ -460,7 +460,7 @@ public void testConvertShouldCreateVarargsArrayForOneOnlyVarargsArguments() { | |
Object[] result = underTest.convert(data, true, parameterTypes, dataProvider, 92); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { new double[] { 1.0 } }); | ||
assertThat(result).containsExactly(new double[] { 1.0 }); | ||
} | ||
|
||
@Test | ||
|
@@ -476,7 +476,7 @@ public void testConvertShouldCreateVarargsArrayForOneLastVarargsArguments() { | |
Object[] result = underTest.convert(data, true, parameterTypes, dataProvider, 93); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { 'a', (byte) 2, new Double[] { 1.0, null } }); | ||
assertThat(result).containsExactly('a', (byte) 2, new Double[] { 1.0, null }); | ||
} | ||
|
||
@Test | ||
|
@@ -492,7 +492,7 @@ public void testConvertShouldCreateVarargsArrayForMultipleOnlyVarargsArguments() | |
Object[] result = underTest.convert(data, true, parameterTypes, dataProvider, 94); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { new long[] { 1, 2, 3 } }); | ||
assertThat(result).containsExactly(new long[] { 1, 2, 3 }); | ||
} | ||
|
||
@Test | ||
|
@@ -508,7 +508,7 @@ public void testConvertShouldCreateVarargsArrayForMultipleLastVarargsArguments() | |
Object[] result = underTest.convert(data, true, parameterTypes, dataProvider, 95); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { "foobar", new long[] { 1, 2, 3 } }); | ||
assertThat(result).containsExactly("foobar", new long[] { 1, 2, 3 }); | ||
} | ||
|
||
@Test | ||
|
@@ -523,6 +523,6 @@ public void testConvertShouldNotSplitIfSingleNonVarargArgumentIsRequired() { | |
Object[] result = underTest.convert(data, false, parameterTypes, dataProvider, 100); | ||
|
||
// Then: | ||
assertThat(result).isEqualTo(new Object[] { TestEnum.VAL1 }); | ||
assertThat(result).containsExactly(TestEnum.VAL1); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we cloud use a helper for creating the array instead of using
new Object[] { ... }
over and over.Do you also think that it would be better for the test cases above to write down the data explicitly instead of reusing the test data somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a fan of creating helper methods for tests. So if it's possible to come up with a descriptive method name I'm for adding it. Maybe something like
assertContainsOnlyObjectArrayWithValues(List, values...)
?I agree that it would be better to write down the data explicitly in the test above.