diff --git a/src/test/java/com/h2/Module3_Test.java b/src/test/java/com/h2/Module3_Test.java index c247e186a..3246dcc24 100644 --- a/src/test/java/com/h2/Module3_Test.java +++ b/src/test/java/com/h2/Module3_Test.java @@ -109,6 +109,10 @@ public void m3_04_testFieldsValueSetWhenConstructorCalled() throws IllegalAccess float[] credits = new float[]{10.0f, 20.0f}; float[] debits = new float[]{5.0f}; final Constructor constructor = constructors[0]; + + int parameterCount = constructor.getParameterCount(); + assertEquals(2, parameterCount, classToFind + " must have a constructor with 2 parameters - credits and debits, both should be of type 'float[]'"); + Object instance = constructor.newInstance(credits, debits); final Field[] fields = savingsCalculator.getDeclaredFields(); @@ -154,6 +158,10 @@ public void m3_06_testSumOfCreditsWorksCorrectly() throws IllegalAccessException float[] credits = new float[]{10.0f, 20.0f}; float[] debits = new float[]{5.0f}; final Constructor constructor = constructors[0]; + + int parameterCount = constructor.getParameterCount(); + assertEquals(2, parameterCount, classToFind + " must have a constructor with 2 parameters - credits and debits, both should be of type 'float[]'"); + Object instance = constructor.newInstance(credits, debits); final String methodName = "sumOfCredits"; @@ -196,6 +204,10 @@ public void m3_08_testSumOfDebitsWorksCorrectly() throws IllegalAccessException, float[] credits = new float[]{10.0f, 20.0f}; float[] debits = new float[]{5.0f, 10.f}; final Constructor constructor = constructors[0]; + + int parameterCount = constructor.getParameterCount(); + assertEquals(2, parameterCount, classToFind + " must have a constructor with 2 parameters - credits and debits, both should be of type 'float[]'"); + Object instance = constructor.newInstance(credits, debits); final String methodName = "sumOfDebits";