• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / javabean-tester / 3227

16 Feb 2026 12:20AM UTC coverage: 87.5% (-0.4%) from 87.852%
3227

push

github

hazendaz
Found possible bug in handling, its not always possible to be purist on current code for equals

noted what the expectation was, its not achieved, so just allow it through.  This was an existing problem that the tests didn't catch due to sub objects.  I had added a test when looking at lombok builder pattern and stumbled onto it.  In the equals only tests, its actually doing almost same thing.  This area is known not strong enough and is additionally using equals verifier to try to compensate.

285 of 331 branches covered (86.1%)

5 of 5 new or added lines in 1 file covered. (100.0%)

67 existing lines in 6 files now uncovered.

525 of 600 relevant lines covered (87.5%)

0.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/src/main/java/com/codebox/instance/ConstructorInstance.java
1
/*
2
 * SPDX-License-Identifier: Apache-2.0
3
 * See LICENSE file for details.
4
 *
5
 * Copyright 2012-2026 hazendaz
6
 *
7
 * Portions of initial baseline code (getter/setter test) by Rob Dawson (CodeBox)
8
 */
9
package com.codebox.instance;
10

11
import java.lang.reflect.Constructor;
12
import java.lang.reflect.InvocationTargetException;
13

14
import org.junit.jupiter.api.Assertions;
15

16
/**
17
 * The Constructor Instance.
18
 */
19
public final class ConstructorInstance {
20

21
    /**
22
     * Prevent Instantiation of a new constructor instance.
23
     */
24
    private ConstructorInstance() {
25
        // Prevent Instantiation
26
    }
27

28
    /**
29
     * New instance.
30
     *
31
     * @param constructor
32
     *            the instance
33
     *
34
     * @return the Object
35
     */
36
    public static Object newInstance(final Constructor<?> constructor) {
37
        try {
38
            return constructor.newInstance();
1✔
UNCOV
39
        } catch (final InstantiationException | IllegalAccessException | InvocationTargetException e) {
×
UNCOV
40
            Assertions.fail(
×
UNCOV
41
                    String.format("An exception was thrown while testing the constructor (new instance) '%s': '%s'",
×
UNCOV
42
                            constructor.getName(), e.toString()));
×
43
        }
UNCOV
44
        return null;
×
45
    }
46

47
    /**
48
     * Constructor inaccessibility test.
49
     *
50
     * @param clazz
51
     *            the clazz
52
     */
53
    public static void inaccessible(final Class<?> clazz) {
54
        final Constructor<?>[] ctors = clazz.getDeclaredConstructors();
1✔
55
        Assertions.assertEquals(1, ctors.length, "Utility class should only have one constructor");
1✔
56
        final Constructor<?> ctor = ctors[0];
1✔
57
        Assertions.assertFalse(ctor.canAccess(null), "Utility class constructor should be inaccessible");
1✔
58
        // Make accessible 'true' in order to test following assert.
59
        ctor.setAccessible(true);
1✔
60
        final Object object = ConstructorInstance.newInstance(ctor);
1✔
61
        Assertions.assertEquals(clazz, object == null ? "null" : object.getClass(),
1!
62
                "You would expect the constructor to return the expected type");
63
        // Set accessible back to 'false'
64
        ctor.setAccessible(false);
1✔
65
    }
1✔
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc