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

Fixes #2510: Remove ExpectedException from internal test suite #2518

Merged
merged 72 commits into from
Dec 24, 2021
Merged
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
90115c7
Replace ExpectedException in AtLeastXNumberOfInvocationsCheckerTest
temp-droid Dec 14, 2021
8be75e6
Replace ExpectedException in TimesTest
temp-droid Dec 14, 2021
bba18bc
Replace ExpectedException in VerificationOverTimeImplTest
temp-droid Dec 14, 2021
5d3e6f4
Replace ExpectedException in MissingInvocationCheckerTest
temp-droid Dec 14, 2021
5b2fe7b
Replace ExpectedException in MockInjectionUsingConstructorTest
temp-droid Dec 15, 2021
fdcec50
Replace ExpectedException in VarargsTest
temp-droid Dec 15, 2021
30b1a6d
Replace ExpectedException in StubbingWithThrowablesTest
temp-droid Dec 15, 2021
a93598a
Replace ExpectedException in VerificationInOrderWithCallsTest
temp-droid Dec 16, 2021
35b3a0b
Reformat previously touched files
temp-droid Dec 16, 2021
36fba92
Replace ExpectedException in DescriptionTest
temp-droid Dec 16, 2021
2c30062
Replace ExpectedException in ChecksTest
temp-droid Dec 16, 2021
baeaa77
Replace ExpectedException in TimerTest
temp-droid Dec 16, 2021
f034dee
Replace ExpectedException in NegativeDurationTest
temp-droid Dec 16, 2021
bf50938
Replace ExpectedException in NumberOfInvocationsInOrderCheckerTest
temp-droid Dec 16, 2021
054a01c
Replace ExpectedException in NumberOfInvocationsCheckerTest
temp-droid Dec 16, 2021
58b7ece
Replace @Test(expected=...) in ConstructionMockTest
temp-droid Dec 17, 2021
08c15fa
Replace @Test(expected=...) in StaticMockTest
temp-droid Dec 17, 2021
8dad4e8
Replace @Test(expected=...) in MocksTest
temp-droid Dec 17, 2021
a271c76
Replace @Test(expected=...) in MockitoTest
temp-droid Dec 17, 2021
96a36e2
Fix actual & expected order in last MockitoTest assertion
temp-droid Dec 17, 2021
21eb375
Replace @Test(expected=...) in MockAnnotationProcessorTest
temp-droid Dec 18, 2021
0f2b920
Replace @Test(expected=...) in MockInjectionTest
temp-droid Dec 18, 2021
3660c41
Replace `isEqualTo(true)` with `isTrue()`
temp-droid Dec 18, 2021
cd6dfe1
Replace @Test(expected=...) in MockSettingsImplTest
temp-droid Dec 18, 2021
d2e47eb
Replace junit assertions with assertj
temp-droid Dec 18, 2021
982b56c
Replace @Test(expected=...) in ConstructorInstantiatorTest
temp-droid Dec 18, 2021
cb96576
Replace junit assertions with assertj
temp-droid Dec 18, 2021
5f6a321
Replace @Test(expected=...) in ReporterTest
temp-droid Dec 18, 2021
c520d44
Replace @Test(expected=...) in DefaultMockitoFrameworkTest
temp-droid Dec 18, 2021
e5a65f6
Replace @Test(expected=...) in AnswersWithDelayTest
temp-droid Dec 18, 2021
19a2c00
Replace @Test(expected=...) in DoesNothingTest
temp-droid Dec 18, 2021
628c234
Replace @Test(expected=...) in ReturnsTest
temp-droid Dec 18, 2021
33098b7
Replace @Test(expected=...) in ThrowsExceptionTest
temp-droid Dec 18, 2021
2a7b4a0
Replace @Test(expected=...) in DefaultMockingDetailsTest
temp-droid Dec 20, 2021
4b9530d
Replace @Test(expected=...) in FieldInitializerTest
temp-droid Dec 20, 2021
ba473ae
Replace @Test(expected=...) in HashCodeAndEqualsSafeSetTest
temp-droid Dec 20, 2021
a30ca41
Replace @Test(expected=...) in MockCreationValidatorTest
temp-droid Dec 20, 2021
e219fc6
Replace @Test(expected=...) in MockInjectionUsingConstructorTest
temp-droid Dec 20, 2021
2fa9b71
Replace @Test(expected=...) in MockUtilTest
temp-droid Dec 20, 2021
42cbd0e
Replace @Test(expected=...) in ResetInvocationsTest
temp-droid Dec 20, 2021
b822744
Replace @Test(expected=...) in ResetTest
temp-droid Dec 20, 2021
2336b7d
Replace @Test(expected=...) in ReturnsGenericDeepStubsTest
temp-droid Dec 20, 2021
f483842
Replace @Test(expected=...) in SpyAnnotationTest
temp-droid Dec 20, 2021
4cedd6c
Replace @Test(expected=...) in WrongSetOfAnnotationsTest
temp-droid Dec 20, 2021
d89abae
Remove unused imports in MockInjectionUsingConstructorTest
temp-droid Dec 20, 2021
39a1ab6
Fix test in SpyAnnotationTest
temp-droid Dec 20, 2021
baa5366
Fix test in ReturnsGenericDeepStubsTest
temp-droid Dec 20, 2021
20108c5
Replace @Test(expected=...) in ClassCastExOnVerifyZeroInteractionsTest
temp-droid Dec 20, 2021
93d8c01
Replace @Test(expected=...) in NPEWithCertainMatchersTest
temp-droid Dec 20, 2021
6eab0df
Replace @Test(expected=...) in BDDMockitoTest
temp-droid Dec 20, 2021
b1c5c7b
Remove @Test(expected=...) in LenientJUnitRuleTest
temp-droid Dec 20, 2021
3417f23
Replace @Test(expected=...) in VerificationCollectorImplTest
temp-droid Dec 20, 2021
a100d94
Remove unused import in VerificationCollectorImplTest
temp-droid Dec 20, 2021
7627fdf
Replace @Test(expected=...) in MatchersTest
temp-droid Dec 21, 2021
db0981b
Replace @Test(expected=...) in ReflectionMatchersTest
temp-droid Dec 21, 2021
a348c26
Replace @Test(expected=...) in DescriptiveMessagesOnMisuseTest
temp-droid Dec 21, 2021
75ccfa3
Replace @Test(expected=...) in InvalidUsageTest
temp-droid Dec 21, 2021
695021d
Replace @Test(expected=...) in StubbingConsecutiveAnswersTest
temp-droid Dec 21, 2021
2efc8a2
Replace @Test(expected=...) in StubbingUsingDoReturnTest
temp-droid Dec 21, 2021
1b4f335
Replace @Test(expected=...) in StubbingWarningsTest
temp-droid Dec 21, 2021
291a04f
Replace @Test(expected=...) in BasicVerificationInOrderTest
temp-droid Dec 21, 2021
c65c55c
Replace @Test(expected=...) in BasicVerificationTest
temp-droid Dec 21, 2021
2dd30c7
Replace @Test(expected=...) in NoMoreInteractionsVerificationTest
temp-droid Dec 21, 2021
0dd975c
Replace @Test(expected=...) in RelaxedVerificationInOrderTest
temp-droid Dec 21, 2021
67436f4
Replace @Test(expected=...) in VerificationExcludingStubsTest
temp-droid Dec 21, 2021
d9edde1
Replace @Test(expected=...) in VerificationInOrderMixedWithOrdiraryVe…
temp-droid Dec 21, 2021
02e57ef
Rename VerificationInOrderMixedWithOrdiraryVerificationTest to Verifi…
temp-droid Dec 21, 2021
797d0a6
Replace @Test(expected=...) in ClassLoadersTest
temp-droid Dec 21, 2021
c2c73be
Replace @Test(expected=...) in SafeJUnitRuleTest
temp-droid Dec 21, 2021
f5e895d
Replace @Test(expected=...) in MockHandlerImplTest
temp-droid Dec 21, 2021
dc2231c
Replace @Test(expected=...) in AtLeastMarksAllInvocationsVerified
temp-droid Dec 21, 2021
367fb12
Replace @Test(expected=...) in InvocationNotifierHandlerTest
temp-droid Dec 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Replace ExpectedException in VarargsTest
  • Loading branch information
temp-droid committed Dec 15, 2021
commit fdcec5039865dcbaa3e85e05fdc98d1447f1cc7f
43 changes: 26 additions & 17 deletions src/test/java/org/mockitousage/matchers/VarargsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
package org.mockitousage.matchers;

import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
Expand All @@ -19,7 +20,6 @@
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatchers;
import org.mockito.Captor;
Expand All @@ -32,7 +32,6 @@
public class VarargsTest {

@Rule public MockitoRule mockitoRule = MockitoJUnit.rule();
@Rule public ExpectedException exception = ExpectedException.none();
@Captor private ArgumentCaptor<String> captor;
@Mock private IMethods mock;

Expand Down Expand Up @@ -104,9 +103,11 @@ public void shouldMatchVarArgs_nullArrayArg() {
public void shouldnotMatchVarArgs_twoArgsOneMatcher() {
mock.varargs("1", "1");

exception.expectMessage("Argument(s) are different");

verify(mock).varargs(eq("1"));
assertThatThrownBy(
() -> {
verify(mock).varargs(eq("1"));
})
.hasMessageContaining("Argument(s) are different");
}

@Test
Expand Down Expand Up @@ -141,9 +142,11 @@ public void shouldMatchVarArgs_twoArgsTwoAnyMatcher() {
public void shouldMatchVarArgs_twoArgsThreeAnyMatcher() {
mock.varargs(1, 2);

exception.expectMessage("Argument(s) are different");

verify(mock).varargs(any(), any(), any()); // any() -> VarargMatcher
assertThatThrownBy(
() -> {
verify(mock).varargs(any(), any(), any()); // any() -> VarargMatcher
})
.hasMessageContaining("Argument(s) are different");
}

@Test
Expand Down Expand Up @@ -261,9 +264,11 @@ public void shouldCaptureVarArgs_oneNullArgument2() {
public void shouldNotCaptureVarArgs_3args2captures() {
mock.varargs("1", "2", "3");

exception.expect(ArgumentsAreDifferent.class);

verify(mock).varargs(captor.capture(), captor.capture());
assertThatThrownBy(
() -> {
verify(mock).varargs(captor.capture(), captor.capture());
})
.isInstanceOf(ArgumentsAreDifferent.class);
}

@Test
Expand Down Expand Up @@ -292,9 +297,11 @@ public void shouldNotCaptureVarArgs_3argsCaptorMatcherMix() {
public void shouldNotCaptureVarArgs_1args2captures() {
mock.varargs("1");

exception.expect(ArgumentsAreDifferent.class);

verify(mock).varargs(captor.capture(), captor.capture());
assertThatThrownBy(
() -> {
verify(mock).varargs(captor.capture(), captor.capture());
})
.isInstanceOf(ArgumentsAreDifferent.class);
}

/**
Expand All @@ -321,9 +328,11 @@ public void shouldCaptureVarArgsAsArray() {
public void shouldNotMatchRegualrAndVaraArgs() {
mock.varargsString(1, "a", "b");

exception.expect(ArgumentsAreDifferent.class);

verify(mock).varargsString(1);
assertThatThrownBy(
() -> {
verify(mock).varargsString(1);
})
.isInstanceOf(ArgumentsAreDifferent.class);
}

@Test
Expand Down