File tree Expand file tree Collapse file tree 3 files changed +32
-4
lines changed
main/java/com/github/karczews/utilsverifier
test/java/com/github/karczews/utilsverifier Expand file tree Collapse file tree 3 files changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -198,8 +198,8 @@ private void verifyPrivateConstructor() {
198198 if (!suppressPrivateConstructorCheck && !Modifier .isPrivate (constructor .getModifiers ())) {
199199 throw new AssertionError ("Constructor should be private" );
200200 }
201- } catch (final NoSuchMethodException noSuchMethod ) {
202- throw new AssertionError (classUnderTest .getSimpleName () + " has no constructor" , noSuchMethod );
201+ } catch (final NoSuchMethodException ignore ) {
202+ throw new AssertionError (classUnderTest .getSimpleName () + " has no constructor" );
203203 }
204204
205205 try {
@@ -213,7 +213,7 @@ private void verifyPrivateConstructor() {
213213 throw new AssertionError ("expected exception: " + expectedConstructorException .getName () +
214214 " got: " + e .getTargetException ().getClass ().getName ());
215215 }
216- } catch (final ReflectiveOperationException e ) {
216+ } catch (final Exception e ) {
217217 throw new IllegalStateException (e );
218218 }
219219 }
Original file line number Diff line number Diff line change 2020import com .github .karczews .utilsverifier .subjects .InstanceMethods ;
2121import com .github .karczews .utilsverifier .subjects .MultipleConstructors ;
2222import com .github .karczews .utilsverifier .subjects .MutableStaticFields ;
23+ import com .github .karczews .utilsverifier .subjects .NoConstructor ;
2324import com .github .karczews .utilsverifier .subjects .NonFinalClass ;
2425import com .github .karczews .utilsverifier .subjects .NonPrivateConstructor ;
2526import com .github .karczews .utilsverifier .subjects .ThrowingConstructor ;
@@ -89,8 +90,9 @@ public void shouldFailOnInstanceMethod() {
8990 }
9091
9192 @ Test
92- public void shouldFailWhenNoConstructor () {
93+ public void shouldFailWhenOnlyADefaultPublicConstructor () {
9394 expectedException .expect (AssertionError .class );
95+ expectedException .expectMessage (containsString ("should be private" ));
9496
9597 suppressedVerifier (DefaultConstructor .class )
9698 .suppressPrivateConstructorCheck (false )
@@ -107,6 +109,16 @@ public void shouldFailWhenNoPrivateConstructor() {
107109 .verify ();
108110 }
109111
112+ @ Test
113+ public void shouldFailWhenNoConstructor () {
114+ expectedException .expect (AssertionError .class );
115+ expectedException .expectMessage (containsString ("has no constructor" ));
116+
117+ suppressedVerifier (NoConstructor .class )
118+ .suppressPrivateConstructorCheck (false )
119+ .verify ();
120+ }
121+
110122 @ Test
111123 public void shouldFailOnMultipleConstructors () {
112124 expectedException .expect (AssertionError .class );
Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright (c) 2017-present, UtilsVerifier Contributors.
3+ * <p>
4+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5+ * compliance with the License. You may obtain a copy of the License at
6+ * <p>
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ * <p>
9+ * Unless required by applicable law or agreed to in writing, software distributed under the License is
10+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11+ * the License for the specific language governing permissions and limitations under the License.
12+ */
13+ package com .github .karczews .utilsverifier .subjects ;
14+
15+ public interface NoConstructor {
16+ }
You can’t perform that action at this time.
0 commit comments