From a991728e0147b65fb4e0c80e9d15f09ace8ad0de Mon Sep 17 00:00:00 2001 From: Hamza Ahmed Khan Date: Fri, 28 May 2021 10:49:22 +0500 Subject: [PATCH] Increase test coverage --- .../widgets/CheckBoxFactoryTest.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/widgets/CheckBoxFactoryTest.java b/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/widgets/CheckBoxFactoryTest.java index f436a79f0..41f371fcb 100644 --- a/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/widgets/CheckBoxFactoryTest.java +++ b/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/widgets/CheckBoxFactoryTest.java @@ -109,4 +109,25 @@ public void testGetCustomTranslatableWidgetFields() { Assert.assertEquals(1, editableProperties.size()); Assert.assertEquals("options.text", editableProperties.iterator().next()); } + + + @Test + public void testPerformValidation() throws Exception { + Assert.assertNotNull(factory); + CheckBoxFactory factorySpy = Mockito.spy(factory); + Assert.assertNotNull(rootLayout); + LinearLayout rootLayoutSpy = Mockito.spy(rootLayout); + + LinearLayout checkboxOptionLayout = Mockito.mock(LinearLayout.class); + CheckBox currentCheckbox = Mockito.mock(CheckBox.class); + + Mockito.doReturn(2).when(rootLayoutSpy).getChildCount(); + Mockito.doReturn(checkboxOptionLayout).when(rootLayoutSpy).getChildAt(Mockito.anyInt()); + Mockito.doReturn(currentCheckbox).when(checkboxOptionLayout).getChildAt(0); + Mockito.doReturn(true).when(currentCheckbox).isChecked(); + + Boolean checked = Whitebox.invokeMethod(factorySpy, "performValidation", rootLayoutSpy); + + Assert.assertTrue(checked); + } }